aspose file tools*
The moose likes JDBC 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
Bookmark "Problem Linking MySQL and Java" Watch "Problem Linking MySQL and Java" New topic
Author

Problem Linking MySQL and Java

Karel Young
Greenhorn

Joined: Mar 02, 2004
Posts: 10
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


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

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: http://aspose.com/file-tools
 
subject: Problem Linking MySQL and Java
 
Similar Threads
how to get the inserted record by using resultset in java?
MySql Lost connection exception under load
Can you use nested sql statements in jsp??
autoincrement invoice
String -> MySQL CLOB