• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getting batch updation exception.

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
While adding batch for updation i am getting strange exception can any body tell me what to do in this case?
I am using prepareStatement for this case.
--
psmt=con.prepareStatement("?");
psmt.setString(1,SBf.toString());
addBatch()
Error is like this when i try to execute executeBatch()
---------------------------
Query built->insert into kemp (EMPNO, ENAME, SAL) values (13,'Try1',1000)
Batch Added
Query built->insert into kemp (EMPNO, ENAME, SAL) values (13,'Try2',1000)
Batch Added
java.sql.BatchUpdateException: ORA-00900: invalid SQL statement
at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:3907)
at TestUtility.elxUpdate(TestUtility.java:132)
at TestUtility.init(TestUtility.java:73)
at TestUtility.<init>(TestUtility.java:43)
at TestUtility.main(TestUtility.java:38)
At end of init()
---------------------------
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are many things wrong when you evaluate what is actually being executed, but it all comes down to the fact that you are abusing the prepared statement. Prepared statements are to be used if you are repeatedly using the same SQL statement, except only the parameter values are changing in the where clause (which are represented by a ? ). You need to use a Statement object to accomplish your goal, or prepareStatement() for each different query.
Solution 1

Solution2

OR something similar to this.
Jamie
 
Jack Nicholson
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Jamie
reply
    Bookmark Topic Watch Topic
  • New Topic