Skip to main content


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 15:57 Go to next message
DK511 is currently offline DK511Friend
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 17:34 Go to previous message
DK511 is currently offline DK511Friend
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 Apr 20 11:15:16 GMT 2024

Powered by FUDForum. Page generated in 0.02447 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top