aspose file tools
The moose likes JDBC and the fly likes Another executeUpdate() ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Another executeUpdate() ?" Watch "Another executeUpdate() ?" New topic
Author

Another executeUpdate() ?

Nick Neidig
Greenhorn

Joined: Aug 29, 2003
Posts: 12
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
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
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
I think closing the statement was the important part here. Removing the System.exit(0) would have probably worked as well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Another executeUpdate() ?
 
Similar Threads
Map Problem
static methods and NULL
Abstract class..
Switch Prog. ,Now In Arrays..???
Confused for threading ?