Bug #9423 Wrong database selected with CONCUR_UPDATABLE
Submitted: 27 Mar 2005 21:21 Modified: 28 Mar 2005 0:19
Reporter: Steve Ryder Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:3.23.58 OS:Linux (Linux Fedora 2)
Assigned to: CPU Architecture:Any

[27 Mar 2005 21:21] Steve Ryder
Description:
stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
                                         ResultSet.CONCUR_UPDATABLE);

Will not use the correct database when the above createStatement is used.
Using stmt = conn.createStatement(); works just fine. 

It does not matter if database was set with USE or is explicitly coded in the select statement. 

Below are log of results (update at top, no update at bottom).
2005-03-27 15:02:00: exception: General error message from server: "Table 'rsa.Text' doesn't exist"
2005-03-27 15:02:00: setSelect: SELECT * FROM reqs.Text WHERE UGPROJ='MVSS' ORDER BY UGREQNO
2005-03-27 15:02:00: 10 rows 43 cols found in result set
2005-03-27 15:02:00: setSelect: SELECT * FROM reqs.Text WHERE UGPROJ='MVSS' ORDER BY UGREQNO
2005-03-27 15:02:00:USE reqs: connection to jdbc/MySql established.

How to repeat:
Go to this link: 
http://app.jsrsys.com/TestApp/dbTest.jsp

From this link you can see the different results (the log above was extracted from the View Status Log link).  The page also has links to a txt file that is the source for the Java class that does all the SQL statements, as well as a txt file for the jsp code for the test page.  

The workaround was to use execUpdate and prepare my own INSERT, DELETE, or UPDATE statements rather than use the update function of JDBC.
[28 Mar 2005 0:19] Mark Matthews
The server does not give information about the database in use or in a query that allows the driver to do this correctly until version 4.1. Please upgrade to Connector/J 3.0.16 or later, and MySQL-4.1 and retest.
[28 Mar 2005 0:36] Steve Ryder
Thank you.  I am glad to know I am not crazy and the the "bug" has been fixed in a later release.
[31 Mar 2014 8:27] Alexander Soklakov
Bug#8491 was marked as duplicate of this report.