File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Establishing Connection to MS Access Databases Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Establishing Connection to MS Access Databases" Watch "Establishing Connection to MS Access Databases" New topic

Establishing Connection to MS Access Databases

Ravi Magod

Joined: Mar 04, 2005
Posts: 1
Hello !

I have been trying to establish a connection to a MS Access Database within my system. I am getting an error of " No driver"

the piece of code is
import java.sql.*;

public class DriverManagerDemo {

public DriverManagerDemo() {

public static void main(String[] args) {

String url="F:/Javfiles/JavaRavi/Listner/JavaTrial.mdb";
System.out.println(" Attempting to connect to "+url);
System.out.println("Loading the driver ...");
System.out.println("Establishing a Connection ..");
Connection C=DriverManager.getConnection(url);
Connection conn = DriverManager.getConnection("jdbc : odbc:"
System.out.println("Connect to "+C.getCatalog()+" a success");
catch(Exception e){


I get this error

Attempting to connect to F:/Javfiles/JavaRavi/Listner/JavaTrial.mdb
Loading the driver ...
Establishing a Connection ..
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at DriverManagerDemo.main(

Can anyone help in sorting this out?


Ravi Magod
Adi Peyyala

Joined: Jan 17, 2005
Posts: 6

Try doing this with your piece of code

Connection c=DriverManager.getConnection(url,"","");
//Connection conn = DriverManager.getConnection("jdbc : odbc:" +url);
System.out.println("Connect to "+c.getCatalog()+" a success");

I think the problem with you code lies in not having specified the username and password fields in the getConnection(). They should be left blank as show above.

Best of Luck
Anandh Ramesh
Ranch Hand

Joined: Dec 15, 2004
Posts: 61

did you try using a dsn for this purpose? i guess that should do the trick.

cheers,<br />Anandh
Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
Connection conn = DriverManager.getConnection("jdbc : odbc:"

Your problem is the spaces around the ":" between jdbc and odbc.

Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
Joe Myn

Joined: Oct 19, 2004
Posts: 25
Hello Ravi,

Have you registered your database as an ODBC database.

If you did that try using the database name instead of the url.

example : connection = DriverManager.getConnection( "jdbc dbc atabaseName", "", "" );
[ March 12, 2005: Message edited by: Joe Myn ]
I agree. Here's the link:
subject: Establishing Connection to MS Access Databases
jQuery in Action, 3rd edition