描述:向Access中插入记录,代码如下:
//将数据插入Access private int addData(List<SummaryPriceInfo> dateListForDownload, String fileUrl) throws Exception{ int rowcount = 0; Connection con = null; PreparedStatement ps = null; try{ System.out.println("fileUrl = "+fileUrl); con = getConnection(fileUrl); con.setAutoCommit(false); ps = con.prepareStatement("INSERT INTO price values(?, ?, ?, ?, ?, ?, ? ,?, ?, ?, ?, ?)"); for (SummaryPriceInfo object : dateListForDownload) { ps.setString(1, (rowcount + 1) +""); ps.setString(2, StringUtil.formatNullToEmpty(object.getRealname())); ps.setString(3, StringUtil.formatNullToEmpty(object.getOscym())); ps.setString(4, StringUtil.formatNullToEmpty(object.getOrgname())); ps.setString(5, StringUtil.formatNullToEmpty(object.getOrgsyssize())); ps.setString(6, StringUtil.formatNullToEmpty(object.getModelid())); ps.setString(7, StringUtil.formatNullToEmpty(object.getRiskcoef())); ps.setString(8, StringUtil.formatNullToEmpty(object.getOscid())); ps.setString(9, StringUtil.formatNullToEmpty(object.getGetaudmoney())); ps.setString(10, StringUtil.formatNullToEmpty(object.getMinimumLimit())); ps.setString(11, StringUtil.formatNullToEmpty(object.getInvoiceno())); ps.setString(12, StringUtil.formatNullToEmpty(object.getSubaudorg())); ps.addBatch(); rowcount ++; } ps.executeBatch(); con.commit(); con.setAutoCommit(true); System.out.println("-----------------数据插入Access 成功!---------------"); }catch(Exception e){ con.rollback(); e.printStackTrace(); throw new Exception(); }finally{ if(ps != null) ps.close(); if(con != null) con.close(); } return rowcount; }
执行到 ps.executeBatch(); 报如下错误!
Unhandled exception
Type=Segmentation error vmState=0x0005ff05
J9Generic_Signal_Number=00000004 ExceptionCode=c0000005 ExceptionAddress=009E0698 ContextFlags=0001003f
Handler1=008B05B0 Handler2=008F74F0 InaccessibleAddress=00000028
EDI=43F87D50 ESI=442012C0 EAX=00000001 EBX=00000000
ECX=44F0C45C EDX=00000000
EIP=009E0698 ESP=421DFAEC EBP=44F0C49C
Module=D:/IBM/SDP70/jdk/jre/bin/j9jit23.dll
Module_base_address=00990000 Offset_in_DLL=00050698
Method_being_compiled=org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.isCompatibleWith(Lorg/eclipse/jdt/internal/compiler/lookup/TypeBinding;)Z
Target=2_30_20060915_08260_lHdSMR (Windows XP 5.1 build 2600 Service Pack 2)
CPU=x86 (2 logical CPUs) (0x7fde9000 RAM)
JVMDUMP006I Processing Dump Event "gpf", detail "" - Please Wait.
JVMDUMP007I JVM Requesting System Dump using 'D:/IBM/SDP70/core.20070814.103226.3596.dmp'
JVMDUMP010I System Dump written to D:/IBM/SDP70/core.20070814.103226.3596.dmp
JVMDUMP007I JVM Requesting Snap Dump using 'D:/IBM/SDP70/Snap0001.20070814.103226.3596.trc'
JVMDUMP010I Snap Dump written to D:/IBM/SDP70/Snap0001.20070814.103226.3596.trc
JVMDUMP007I JVM Requesting Java Dump using 'D:/IBM/SDP70/javacore.20070814.103226.3596.txt'
JVMDUMP010I Java Dump written to D:/IBM/SDP70/javacore.20070814.103226.3596.txt
JVMDUMP013I Processed Dump Event "gpf", detail "".
在网上查得说用以下方法修正。
打开tomcatHome/bin/tomcat5w.exe,点击Java选项卡,然后将会发现其中有这么两项:
Initial memory pool和Maximum memory pool.
Initial memory pool这个就是初始化设置的内存的大小。
Maximum memory pool这个是最大内存的大小
将其中的Initial memory pool设置为64MB.!!!Success!!!
设置完了就按确定然后再重启TOMCAT你就会发现tomcat中jvm可用的内存改变了
但是试验没有成功还是报上面同样的错误,经查得向Access中插入记录,对于同一个字段,如果插入值就有NULL也有空串,则出现上面错误,如果同为NULL或同为空串,不报错!不知道为什么?