This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes getting batch updation exception. 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 "getting batch updation exception." Watch "getting batch updation exception." New topic
Author

getting batch updation exception.

Jack Nicholson
Ranch Hand

Joined: Sep 07, 2002
Posts: 41
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()
---------------------------


Jack Nicholson
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

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

Joined: Sep 07, 2002
Posts: 41
Thanx Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting batch updation exception.
 
Similar Threads
Order by query..
Error Processing Resource
Error Processing Resource
Please help : toByteArray(myBlob) fails ???
can a batch have multiple prepared statements