The class runs without exception, but the values 55 and CD Player do not appear in the Access table Customer1 after I run the class. Thanks for your help. Nick package be314; import java.sql.*; public class TestUpdate { public static void main (String args []) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c = DriverManager.getConnection( "jdbc dbc:Music"); Statement s = c.createStatement(); s.executeUpdate ("INSERT INTO Customer1 VALUES (55, 'CD Player')"); System.exit(0); } catch (SQLException bb) { System.out.println(bb); System.exit(0); } catch (ClassNotFoundException cc) { System.out.println(cc); System.exit(0); } } }
Lu Battist
Ranch Hand
Joined: Feb 17, 2003
Posts: 104
posted
0
This is strange. If it is running with no exceptions, the likly cause is that it is not being committed to the database. Try this, c.setAutoCommit(true); right after you get the connection. Also be sure to close your statement and especially the connection after your done with them.
Nick Neidig
Greenhorn
Joined: Aug 29, 2003
Posts: 12
posted
0
Thanks again Lu I got the results to show up in the database. I experimented with including setAutoCommit(true) and the closing statements in my class and found that the results show up correctly with or without the setAutoCommit(true).
Dana Hanna
Ranch Hand
Joined: Feb 28, 2003
Posts: 227
posted
0
I think closing the statement was the important part here. Removing the System.exit(0) would have probably worked as well.