Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MySQL and updatable result sets

5 views
Skip to first unread message

Steve

unread,
Apr 8, 2002, 10:03:15 PM4/8/02
to
I thought that the current JDBC driver for MySQL supported updatable
result sets.

I have the following to load the driver:

Class.forName("org.gjt.mm.mysql.Driver").newInstance();

then get a connection to the db, and then create a statement with:

stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);

When I try to update my result set with rs.updateString(1, "Hello") I
get the following:

java.sql.SQLException: ResultSet not updatable
at org.gjt.mm.mysql.jdbc2.ResultSet.generateStatements(ResultSet.java:2283)
at org.gjt.mm.mysql.jdbc2.ResultSet.syncUpdate(ResultSet.java:2346)
at org.gjt.mm.mysql.jdbc2.ResultSet.updateString(ResultSet.java:1066)
at JDBCDemo.main(JDBCDemo.java:21)

It seems like the early methods in the stack trace wouldn't exist if
the possibility of updatable didn't exist, but despite my request for
updatable, the result set apparently isn't. I'm not doing anything
fancy in the query--no joins or anything--just a simple select a
couple fields from a table.

Any thoughts?

Does the source for the Driver and associated classes exist anywhere I
can get a look at them?

Steve

Mark Matthews

unread,
Apr 9, 2002, 7:28:43 PM4/9/02
to
Check the README that comes with the driver. This issue is described in
there. It boils down to the fact that for a result set to be updatable, the
query that created it has to select all of the primary keys in the table,
and the query can only reference one table so that the row can be uniquely
identified. This restriction is due to the fact that MySQL does not have the
concept of "row identifiers", and in this case, the JDBC spec says that the
driver can require the above conditions. If you don't have any primary keys
in your table, you will have to add them for this to work.

-Mark

"Steve" <pimen...@cs.com> wrote in message
news:4030dd43.02040...@posting.google.com...

PimentoTR6

unread,
Apr 14, 2002, 10:19:12 AM4/14/02
to
>Check the README that comes with the driver. This issue is described in
>there. It boils down to the fact that for a result set to be updatable, the
>query that created it has to select all of the primary keys in the table,
>and the query can only reference one table so that the row can be uniquely
>identified. This restriction is due to the fact that MySQL does not have the
>concept of "row identifiers", and in this case, the JDBC spec says that the
>driver can require the above conditions.

Thanks for the assistance.

FYI, in the version I downloaded, mm.mysql-2.0.4-bin.jar, the README file does
not mention anything about this.

Steve

Ed Yu

unread,
Apr 14, 2002, 1:21:45 PM4/14/02
to
Try to get it from sourceforge.net and go to group MM MySQL, the current
version is 2.0.12.

"PimentoTR6" <pimen...@cs.compost> wrote in message
news:20020414101912...@mb-de.news.cs.com...

0 new messages