Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem Linking MySQL and Java

 
Karel Young
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a problem in that I am getting an error instead of an empty ResultSet
TestCode
//Open Database
cc.DBOpen();
//Create Table
cc.DBUpdate("create table tblCustomer1 (id numeric(5), name character(20), address1 character(20), address2 character(20), phone character(20), email character(20), Loyalty_points numeric(5), primary key(id))");
//Close Database to Commit Changes
cc.DBClose();

//Open Database
cc.DBOpen();
//Run Query;
java.sql.ResultSet rs = cc.DBQuery("Select * from tblCustomer1");
//Close Database
cc.DBClose();
/*This Command Crashes
*Errorjava.lang.Exception: SELECT * FROM tblCustomer1
*There was an issue Retrieving all the Data from the Database:
*java.sql.SQLException: [unixODBC][MySQL][ODBC 3.51 Driver][mysqld-4.0.18-log]Table 'test.TBLCUSTOMER1' doesn't exist
*instead of returning an empty Resultset
*/
:cc is the class doing the links to the Database but that side of it works fine:
Under Windows I do not get the error but Under Linux (MySQL) I do.
When I run the Query direct to MySQL I get "Empty Set (0.00 sec)"

Any help would be appreciated
 
Karel Young
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added a null Check
if (!(rs==null)){...
To my code and that has gotten around the problem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic