• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

problem in using addBatch

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
}
}

>
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nagendra,
Can you simplify the problem? If you pass less parameters, does the problem still occur?
 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Nagendra Batchu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya...now i am not using batchs , i am inserting the record one by one
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();
 
today's feeble attempt to support the empire
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic