This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC

 
Richard Robbins
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Terry McKee
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic