wood burning stoves 2.0*
The moose likes JDBC and the fly likes how to connect ms acess in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to connect ms acess in java" Watch "how to connect ms acess in java" New topic
Author

how to connect ms acess in java

basanta dwibedy
Greenhorn

Joined: Feb 05, 2007
Posts: 23
hi i am trying to connect ms access through java but its having error data source name not found.
But i have created data source already in controlpanel---.> admistretive tool--> data source --> DBCON and configure to my data base file Test.mdb .

please help me regarding


public Connection getConnection() throws SQLException
{
try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();

String path="D:/database/Test.mdb";
String database = "jdbcdbcBCON={Microsoft Access Driver (*.mdb)};DBQ= "+path+";;DriverID=22;READONLY=true";

conMain = DriverManager.getConnection(database,"","");

}

catch(Exception e)
{ e.printStackTrace();
}

return conMain;
}


ERRor------------->
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not fou
nd and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3074)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:3
23)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at com.adp.test.util.DBMSConnection.getConnection(DBMSConnection.java:30
)


please guide me. if some where wrong.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

hope this article will be helpful to you.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
 
jQuery in Action, 2nd edition
 
subject: how to connect ms acess in java
 
Similar Threads
Connecting To Database
Connecting to DB Error
connecting to ms access database
JdbcOdbc Connection
URL error (DSN not found)