我想在dabase插入與下面的代碼錯誤在JDBC
try{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:ProductDSN";
Class.forName(driver);
Connection con = DriverManager.getConnection(url);
System.out.println("Connection established");
System.out.println("clear point 1");
String sql = "INSERT INTO product
(id,productName,category,price,availability,quantity,description)
VALUES('ID','name','catag','price','avail','quantity','discript')";
System.out.println("clear point 2");
PreparedStatement stmt = con.prepareStatement(sql);
System.out.println("clear point 3");
stmt.executeUpdate();
System.out.println("clear point 4");
JOptionPane.showMessageDialog(null, "Record Save Successfully");
if (con != null)
stmt.close();
con.close();
System.out.println("Connection Closed");
}
catch(SQLException sqle)
{
System.err.println("Error is in save method");
System.err.println(sqle);
}
及以下插入statment是編譯錯誤..
Connection established
clear poitn 1
clear point 2
clear point 3
Error is in save method
java.sql.SQLException: General error
表的所有數據類型都只是varchar? – Ashok
請提供堆棧跟蹤 – 2013-12-09 06:08:26
請檢查'id','price'和'quantity'的數據類型,無論它們是整數還是varchar – rachana