我正在用 Java (NetBeans 7.3.1) 编写一个简单的 GUI 应用程序,其中我使用 ResultSet 来检索和更新 NetBeans 虚拟数据库中的数据。
我在其中创建了数据库“Employees”和一个表“WORKERS”。艰难,我无法更新其中的数据。
代码是
public void doConnect() {
String host = "jdbc:derby://localhost:1527/Employees";
String uName = "adm";
String uPass = "admin";
String SQL = "SELECT * FROM APP.WORKERS ORDER BY ID";
try {
con = DriverManager.getConnection(host, uName, uPass);
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(SQL);
int conc = rs.getConcurrency();
System.out.println(conc);
rs.next();
int id_col = rs.getInt("ID");
String first_name = rs.getString("First_Name");
String last_name = rs.getString("Last_Name");
String job = rs.getString("Job_Title");
System.out.println(id_col + " " + first_name + " " + last_name + " " + job);
textId.setText(Integer.toString(id_col));
textName.setText(first_name);
textLast.setText(last_name);
txtJob.setText(job);
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}
结果getConcurrency();
是 1007(只读)。我做错了什么?我找不到错误。