updating or inserting database problem

Hi,

I have a problem when i try to insert or update records within database from java, i m using ms access.

I can retrive the data from the table but when i insert or update it , the code executes without any error but has no effect on the table.

I would be thankful if u guyz help me out .

The code is below :

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//loading drivers

Connection conn = DriverManager.getConnection("jdbc:odbc:client");

Statement s = conn.createStatement();

ResultSet rs = s.executeQuery("insert into client (name,hours,minutes) values ('ik',2,34)");

/*int c = s.executeUpdate("insert into client (name,hours,minutes) values ('ik',2,34)");

rs.absolute(2);

rs.updateString("Name","dla");

rs = s.executeQuery("commit");*/

rs.close();

s.close();

conn.close();

[881 byte] By [Ibrahim_codera] at [2007-11-26 13:29:39]
# 1
You havent invoked updateRow on the result set after updating the values. That may be the reason.
LRMKa at 2007-7-7 20:34:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
try the executeUpdate(...) logic that you have commented instead of executeQuery.To make sure it is executed, do an conn.commit() after it.
g_magossa at 2007-7-7 20:34:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

Thanks for reply, i appreciate the help u guyz hav givin me

they wer helpful upto some extent but the actual problem with

my coding was that statment s variable is used with to different

sql queries ,

when i used s variable with a single query the base table was affected with the coding changes.

Thanks once again guyz....!

Ibrahim_codera at 2007-7-7 20:34:19 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...