I seriously need your help with JDBC !!!

Hi,

I'm currently developing a java application that accesses a Microsoft Access database. I used prepared statement to insert a new record in a particular table and it works. The problem is that when I tried to update a record in that table with a prepared statement, a "driver not capable " SQL exception appeared.

PreparedStatement creditBalance = con.prepareStatement(

"UPDATE Accounts SET Balance = Balance + ? WHERE AccountNumber = ?");

creditBalance.setLong(1, addMoney);

creditBalance.setLong(2, 2022333);

creditBalance.executeUpdate();

When I did the same thing with a standard statement (Statement object) and it gave me " too few parameters, expected 1" SQL exception.

Statement stmt = con.createStatement();

String creditString = "UPDATE Accounts " + "SET

Balance = Balance + addMoney "

+ "WHERE AccountNumber =

2022333";

stmt.executeUpdate(creditString);

Does any one knows how can I solve this problem (I need it urgently please !!!)

Many thanks

[1075 byte] By [helen_b] at [2007-9-26 1:32:52]
# 1

The SQL string that your Statement is sending to the database is this:

UPDATE Accounts SET Balance = Balance + addMoney WHERE AccountNumber = 2022333

and the error message from the database likely means that you don't have a column called addMoney in the Accounts table. I suggest that what you wanted to do was this:

String creditString =

"UPDATE Accounts SET Balance = Balance + " + addMoney + " WHERE AccountNumber = 2022333";

DrClap at 2007-6-29 1:34:32 > top of Java-index,Archived Forums,Java Programming...
# 2
Hi,I tried what you suggested and it works. Thank you very much for your valuable reply. I'm a begginer in this area, that is why I'm facing this kind of problems due to lake of experience. Thanks again
helen_b at 2007-6-29 1:34:32 > top of Java-index,Archived Forums,Java Programming...