Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Invalid cursor state when trying to insert record

843859Jun 7 2006 — edited Jun 7 2006
Hi everyone!
I'm using JDBC-ODBC bridge to connect to a mySql database, which works fine. Then I try to insert new records, but this only works for the first record in the table.
When there is already a record in the table, I always get "[Microsoft][ODBC Driver Manager] Invalid cursor state" when calling the updateRow()-method of the result set.

Here is my code:
            // open db connection
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection conn = DriverManager.getConnection("jdbc:odbc:TTManager", "xxxx", "xxxx");
            // Prepare SQL statement
            java.sql.Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
            
            ResultSet result = stmt.executeQuery("SELECT * FROM Player");
            result.moveToInsertRow();
Then all fields are filled in this manner:
            result.updateString("Name", name);
And finally the insertRow should be written to the db:
            result.insertRow();
But at this point it gives the mentioned error, including these messages:
        at sun.jdbc.odbc.JdbcOdbcResultSet.setPos(JdbcOdbcResultSet.java:5272)
        at sun.jdbc.odbc.JdbcOdbcResultSet.insertRow(JdbcOdbcResultSet.java:4132)
Since I'm very unexperienced with Java, I guess (or hope^^) it's just some stupid beginner's mistake.

Oh, almost forgot to mention: The new record's data doesn't violate any unique-constraints on the table, all fields are explicitely filled and all variable's data types are matching their according field types!

Any help would be appreciated!

reinski
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2006
Added on Jun 7 2006
1 comment
259 views