Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC" Watch "JDBC" New topic
Author

JDBC

Richard Robbins
Ranch Hand

Joined: Mar 07, 2001
Posts: 66
I have created an Access database file called ReceiveProcessTest.mdb with a table called Employees. I am testing querying the table, but I am having trouble. Here is my code:

String data = "jdbc dbc eluxeCD";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection receiveQueueConnection = DriverManager.getConnection(data, "", "");
Statement writeToQueue = receiveQueueConnection.createStatement();
ResultSet receiveRec = writeToQueue.executeQuery("SELECT LastName FROM " +
"ReceiveProcessTest.mdb Employees WHERE FirstName LIKE Richard");
An exception keeps being thrown with this message:

Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] The Micr
osoft Jet database engine cannot find the input table or query 'mdb'. Make sure
it exists and that its name is spelled correctly.

The Data Source administrator shows that there are two "User DSN" drivers installed: DeluxeCD and MS Access Database.
If anyone has any solution to this error, please let me know.
Thanks,
Richard


Richard Robbins is one of the founders of WebsiteTemplateDatabase.com, a resource for free website templates and Photoshop tutorials. He also consults for an online boutique selling baptism dresses and christening gowns.
Terry McKee
Ranch Hand

Joined: Sep 29, 2000
Posts: 173
Just a simple change in your sql statement will get rid of the error. You have the following:
SELECT LastName FROM ReceiveProcessTest.mdb Employees WHERE FirstName LIKE Richard"
You don't need to mention the database name since the jdbc dbc Url already defines it. Also I believe the LIKE argument needs single quotes around it. Change the sql statement to the following:
"SELECT LastName From Employees WHERE FirstName Like 'Richard'"
Hope this helps.
 
Don't get me started about those stupid light bulbs.
 
subject: JDBC