} Where conn is a Connection object that connects to JDBC-ODBC When I tried to run it, I expect it to update the Database but it does not and no exception is reported. Please, tell me where the problem is.
Try to avoid the JDBC-ODBC bridge. It ha s bug that caches some statements so they don't actually get to the database. To get the statement to run, either set autocommit(true) on the connection, or run a dummy select (ie a valid select operation, but you don't care about the result) on the dtaabase.
Brian Mozhdehi
Ranch Hand
Joined: Aug 17, 2006
Posts: 81
posted
0
Actually, the issue is not the connection (I have never seen the JDBC-ODBC bridge do that, BTW.). The issue is ps.executeUpdate
Originally posted by Femi Ojambati: Hi All, Please, help me check this code
public Data class{ .... private static void new(){ PreparedStatement ps = conn.prepareStatement("INSERT INTO Members " + "VALUES(?, ?, ?, ?)"); ps.setString(1, "14"); ps.setString(2, "Mike"); ps.setString(3, "Nwabikwo"); ps.setString(4, "14/10/2008"); ps.executeUpdate(); }
public static void main(String [] arg){
.... new(); }
} Where conn is a Connection object that connects to JDBC-ODBC When I tried to run it, I expect it to update the Database but it does not and no exception is reported. Please, tell me where the problem is.
try the query in this way: 1) INSERT INTO Members (columnName1, columnName2, columnName3, to_char(columnName4,'dd/mm/yyy') VALUES(?, ?, ?, ?)"
2) always close the connection and commit the record ps.close(); cnn.commit();
Hope this will help to solve your problem
Thanks
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
4
posted
0
Originally posted by Femi Ojambati: .... new();
How do you get it to compile when you are using a keyword like that? Please look at this FAQ.