我正在使用CachedRowSet
。但是當我調用insertRow()
方法時,有一個SQLException
未能插入行。CachedRowSet未能插入行
這裏是我的代碼:
static final String DATABASE_URL = "jdbc:mysql://localhost:3306/javapos";
static final String USERNAME = "root";
static final String PASSWORD = "sbc";
public static void main (String [] agr) throws SQLException
{
CachedRowSetImpl rs = new CachedRowSetImpl();
rs.setUrl(DATABASE_URL);
rs.setUsername(USERNAME);
rs.setPassword(PASSWORD);
rs.setCommand("select * from uom order by itemid");
rs.execute();
while(rs.next()){
System.out.println(rs.getString("itemid") + " - " + rs.getString("uom"));
}
rs.moveToInsertRow();
rs.updateString(2,"Sample code");
rs.insertRow();
rs.moveToCurrentRow();
rs.acceptChanges();
}
請包括錯誤堆棧跟蹤。 – 2014-09-13 03:47:50
異常在線程 「主要」 值java.sql.SQLException:無法在插入行 \t在com.sun.rowset.CachedRowSetImpl.insertRow(CachedRowSetImpl.java:5449) \t在purchases.NewClass.main(NewClass.java:39 ) Java結果:1 – ram 2014-09-13 03:51:56
應該有比這更多的信息。 – 2014-09-13 04:08:00