aspose file tools*
The moose likes JDBC and the fly likes problem in using addBatch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "problem in using addBatch" Watch "problem in using addBatch" New topic
Author

problem in using addBatch

Nagendra Batchu
Ranch Hand

Joined: Jan 23, 2008
Posts: 32
Could any one can help me solving this problem...i am using addBatchs ...

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Option type out of range
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLSetStmtAttr(JdbcOdbc.java:5251)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setStmtParameterSize(JdbcOdbcPreparedStatement.java:1866)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeBatchUpdate(JdbcOdbcPreparedStatement.java:1644)
at sun.jdbc.odbc.JdbcOdbcStatement.executeBatch(JdbcOdbcStatement.java:912)
at com.dms.data.PrimaryUpload.insertPrimaryUploadDetails(PrimaryUpload.java:418)
at com.dms.action.PrimaryUploadDetails.execute(PrimaryUploadDetails.java:188)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Option type out of range
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLSetStmtAttr(JdbcOdbc.java:5251)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setStmtParameterSize(JdbcOdbcPreparedStatement.java:1866)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeBatchUpdate(JdbcOdbcPreparedStatement.java:1644)
at sun.jdbc.odbc.JdbcOdbcStatement.executeBatch(JdbcOdbcStatement.java:912)

and the code is ----------------->

Set keyss=invoiceItemDetails.keySet();
statement3=connection.prepareStatement("insert into TRANSMASTER(INVOICENO,INVOICEDATE,QUANTITY,SOLDBY,SOLDTO,TRANSNO,ITEMCODE,SEQID,CIRCLEID,TRANSDATE) values (?,?,?,?,?,?,?,?,?,sysdate)");
for(Iterator iterator=keyss.iterator();iterator.hasNext();){
String key = (String) iterator.next();
ArrayList keyValues=new ArrayList();
keyValues=(ArrayList)invoiceItemDetails.get(key);
Set setValues=new HashSet();
for(int k=0;k<keyValues.size();k++){
setValues.add((String)keyValues.get(k));
}

for(int m=0;m<keyValues.size();m++){
int valueCount=0;
if(setValues.contains(keyValues.get(m))){
valueCount++;
}
itemCount.put(keyValues.get(m),valueCount+"");
}

Set itemskeys=itemCount.keySet();
for(Iterator iterator1=itemskeys.iterator();iterator1.hasNext();){
String itemKey= (String) iterator1.next();

statement3.setString(1, key);

statement3.setString(2,(String)invoiceNumberInvDate.get(key));
statement3.setInt(3,Integer.parseInt((String)itemCount.get(itemKey)));
statement3.setString(4,"AIRCEL");
statement3.setString(5,"DISTRIBUTOR");
statement3.setInt(6,maxTrans);
statement3.setString(7,itemKey);
statement3.setInt(8,1);
statement3.setString(9,circleId);
//statement3.executeUpdate();
statement3.addBatch();
}
}

>
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
134

Nagendra,
Can you simplify the problem? If you pass less parameters, does the problem still occur?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jhakda Velu
Ranch Hand

Joined: Feb 26, 2008
Posts: 166
Nagendra
Does the code work if you do single inserts? For all data sets? I suspect that your data has some value which is out of range.

Jhakda


If I become filthy rich, I'll sponsor research for painless dental treatment at Harvard Medical School. Thats why,I'm learning Java.I have 32 teeth, 22 are man made.
Nagendra Batchu
Ranch Hand

Joined: Jan 23, 2008
Posts: 32
Hi all,

Its working fine , if i replace the addBatch() and executeBatch() with executeUpdate()method...i am dealing with large number of records , so i want to use batchs to improve the performance.
Jhakda Velu
Ranch Hand

Joined: Feb 26, 2008
Posts: 166
I didn't get.
You mean to say that you are not using batch now and inserting records one by one?

Jhakda
Nagendra Batchu
Ranch Hand

Joined: Jan 23, 2008
Posts: 32
ya...now i am not using batchs , i am inserting the record one by one
Charbel Keyrouz
Ranch Hand

Joined: Jun 10, 2005
Posts: 46
try inserting every 1000 records
put a counter that will be incremented each time you say: statement3.addBatch();

once the counter reaches 1000 say
statement3.executeBatch();
statement3.clearBatch();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in using addBatch
 
Similar Threads
Simple JDBC question
Passing data from text file to table.
Simple mdb connection Error
Data source name not found and no default driver specified
Joining 3 Tables