This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases 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 Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "getting batch updation exception." Watch "getting batch updation exception." New topic

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.
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(
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(
at TestUtility.elxUpdate(
at TestUtility.init(
at TestUtility.<init>(
at TestUtility.main(
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


OR something similar to this.
Jack Nicholson
Ranch Hand

Joined: Sep 07, 2002
Posts: 41
Thanx Jamie
I agree. Here's the link:
subject: getting batch updation exception.
It's not a secret anymore!