Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Microsoft Access database with Eclipse
Microsoft Access database with Eclipse [message #529014] Thu, 22 April 2010 11:57 Go to next message
DK511 is currently offline DK511
Messages: 2
Registered: April 2010
Junior Member
Hi, I want to access a .dmb database with eclipse.
I'm still learning about that.
Here is the code I use to test


import java.sql.*;
import java.io.*;

public class ConnectDB
{
public static Connection con;
public static final String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
public static final String url = "jdbc.odbc:" + "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=";
String path;


public ConnectDB()
{
path = "c:\test.mdb";
}

public void go()
{
makeConnection();
closeConnection();
}

private void makeConnection()
{
System.out.println("Opening databse... \n");
try
{
Class.forName(driver);
con = DriverManager.getConnection(url + path);
}
catch(Exception ex)
{
System.out.println("Error opening the database!");
System.out.println(ex);
System.exit(0);
}
System.out.println("Success!");
}

private void closeConnection()
{
System.out.println("\nClosing database.");
try
{
con.close();
}
catch (Exception ex)
{
System.out.println("Error closing the database");
System.out.println(ex);
}
}

public static void main(String[] args)
{
ConnectDB test = new ConnectDB();
test.go();
}
}



However I got the error
Opening databse...

Error opening the database!
java.sql.SQLException: No suitable driver found for jdbc.odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c: est.mdb




I'm using 64-bit windows. Because 64-bit doesn't have Microsoft Access Driver, I have setup the DSN for the driver in 32-bit by going to "%WINDIR%\SysWOW64\odbcad32.exe"

But I'm still getting the error.

How should I change the line "public static final String url = "jdbc.odbc:" + "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=";" to make it work? basically, how to make it look into the 32-bit driver, not 64-bit. Is there any setting I need to change?


Thank you.
Re: Microsoft Access database with Eclipse [message #529042 is a reply to message #529014] Thu, 22 April 2010 13:34 Go to previous message
DK511 is currently offline DK511
Messages: 2
Registered: April 2010
Junior Member
nevermind the above question. I know what is the problem now. I need a .jar file driver.

Does anyone know where can I download one for free? I looked into this http://developers.sun.com/product/jdbc/drivers/search_result s.jsp?jdbc_version=0&vendor_name=&cert_mode=and& jdbc_driver_type_mode=and&dbms=6&dbms_mode=and&f eatures_mode=and&results_per_page=50&submit=Search

but they are either paid or trial.


Thank you.
Previous Topic:Problem with text editor going blank. Restart doesn't fix.
Next Topic:Error during update
Goto Forum:
  


Current Time: Sat Aug 02 04:48:17 EDT 2014

Powered by FUDForum. Page generated in 0.04116 seconds