Reputation: 305
I'm working on database containing 2 columns (NOM (String) ,TMP(integer)). But when I tried to update it , the first row became the last. Can I update it and maintain the same order?
Statement state = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet result = state.executeQuery("SELECT * FROM cities");
result.absolute(1);
result.updateString("NOM", "xxx");
result.updateRow();
Here's my databasebefore and after the excution of my code.
Upvotes: 2
Views: 104
Reputation: 10974
The results are displayed ordered by primary key. Since you changed the primary key nom
field the ordering changed as well.
Upvotes: 1
Reputation: 4268
Brent is correct. Normally the results are sorted by primary key in the tables. As you changed the primary key so it is showing the updated order.
Upvotes: 1