Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes JDBC and Relational Databases and the fly likes Problem Linking MySQL and Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem Linking MySQL and Java" Watch "Problem Linking MySQL and Java" New topic

Problem Linking MySQL and Java

Karel Young

Joined: Mar 02, 2004
Posts: 10
I am having a problem in that I am getting an error instead of an empty ResultSet
//Open Database
//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

//Open Database
//Run Query;
java.sql.ResultSet rs = cc.DBQuery("Select * from tblCustomer1");
//Close Database
/*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

"We have a choice: the Internet or a life"
Karel Young

Joined: Mar 02, 2004
Posts: 10
I added a null Check
if (!(rs==null)){...
To my code and that has gotten around the problem
I agree. Here's the link:
subject: Problem Linking MySQL and Java
jQuery in Action, 3rd edition