Insert record into Microsoft Access
Hi folks:
I followed The JAVA TM Tutorial and used JDBC-ODBC bridge creating a database in Microsoft Access, it worked .
NAMEVARCHAR(32)(PRIMARYKEY),
PID INTEGER
PRICEFLOAT
SALESINTEGER
TOTALINTEGER
The following code is to insert the record into Table5. It has been well compiled and executed with no exception message, but I can not get the record in the Access actually. Could you kindly tell me the problem?
Thank you very much
Dawei
public class Insert {
public static void main (String args[]) {
String Url = "jdbc:odbc:mage";
String user = "";
String password ="";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (Exception e) {
System.out.println("Failed to load JDBC/ODBC driver.");
return;
}
try {
Connection con=DriverManager.getConnection(Url,user,password);
Statement statement=con.createStatement();
=====================================================
statement.executeUpdate(
"INSERT INTO Table4 " +
"VALUES ('Cola', 101, 7.99, 0,10)");
====================================================
} catch (Exception e) {
e.printStackTrace();
}
}
}

