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.
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() ---------------------------
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