Forget the stack trace Sorry.
org.h2.jdbc.JdbcSQLException: The result set is not updatable. The
query must select all columns from a unique key. Only one table may be
selected. [90127-111]
at org.h2.message.Message.getSQLException(Message.java:107)
at org.h2.message.Message.getSQLException(Message.java:118)
at org.h2.message.Message.getSQLException(Message.java:77)
at org.h2.message.Message.getSQLException(Message.java:153)
at org.h2.jdbc.JdbcResultSet.getUpdatableRow(JdbcResultSet.java:2914)
at org.h2.jdbc.JdbcResultSet.deleteRow(JdbcResultSet.java:2861)
at org.plr.database.TestDB.testRowDelete(TestDB.java:48)
On Apr 25, 10:22 am, Pierre-Luc <[email protected]> wrote:
> Hello I'm new with H2 I try to execute a simple resultSet.deleteRow()
> and it doesn't work. I'm using the h2-1.1.111 version.
>
> Here the test code
>
> import java.sql.ResultSet;
> import java.sql.SQLException;
> import java.sql.Statement;
>
> import org.h2.jdbcx.JdbcConnectionPool;
> import org.junit.Test;
>
> public class TestDB {
>
> @Test
> public void testRowDelete() throws SQLException {
>
> JdbcConnectionPool cp =
> JdbcConnectionPool.create("jdbc:h2:~/test2",
> "sa", "");
>
> java.sql.Connection con = cp.getConnection();
>
> Statement stmt = con.createStatement();
>
> stmt.execute("Create Table TEST(ID INT , ID2 INT) ");
>
> stmt.close();
> try {
> stmt = con.createStatement();
>
> String query = "INSERT INTO TEST VALUES(0, 4)";
>
> for (int i = 0; i < 5; i++) {
>
> query += ",(" + i + ", 3)";
> }
>
> stmt.execute(query);
>
> stmt.close();
>
> query = "SELECT * FROM TEST";
>
> stmt =
> con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
> ResultSet.CONCUR_UPDATABLE);
>
> ResultSet resultSet = stmt.executeQuery(query);
>
> while (resultSet.next()) {
>
> resultSet.deleteRow();
> }
>
> } finally {
> stmt = con.createStatement();
>
> stmt.execute("DROP Table TEST");
>
> stmt.close();
> }
> }
>
> }
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---