hey,
hab probs mit "updateString" und wie man im anhang sieht, hab ich doch einen primary key?!
was soll ich machen...hab schon alles probiert....
und wenn ich schon hier bin, welcher befehl, hägt neue daten an...
console: mit fehler
msql test >
result:
struktur der mySQL tabelle im anhang
hab probs mit "updateString" und wie man im anhang sieht, hab ich doch einen primary key?!
was soll ich machen...hab schon alles probiert....
und wenn ich schon hier bin, welcher befehl, hägt neue daten an...
Java:
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost/java","root", "");
Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
ResultSet srs = stmt.executeQuery("SELECT name FROM test WHERE ID = 2");
srs.next();
System.out.println("name: "+ srs.getString(1));
srs.updateString("name", "alex");
srs.updateRow();
srs.close();
stmt.close();
HTML:
name: jac
com.mysql.jdbc.NotUpdatable: Result Set not updatable (references no primary keys).This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.
msql test >
SQL:
explain SELECT ID, name FROM test WHERE ID=2 FOR UPDATE
HTML:
id -- select_type --table --type -- possible_keys -- key ----- key_len -- ref -- rows -- Extra
1 -- SIMPLE ------ test -- const -- PRIMARY ------ PRIMARY ----- 4 ----- const -- 1 --
struktur der mySQL tabelle im anhang
Zuletzt bearbeitet: