The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2000



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Creating an MS Acess Database connection

Posted by Anil on November 21, 2000 at 4:56 PM

Add that entry of the Access database in the User DSN (Control Panel -> ODBC Data Sources -> select Access Driver). Once that is done u can use that datasource in ur java code using the sun provided jdbc-odbc drivers.
given below is the code:
String url = "jdbc:odbc:Books"; //books is the name of DSN
String username = "anonymous";
String password = "guest";

// Load the driver to allow connection to the database
try {
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
connection = DriverManager.getConnection(
url, username, password );
catch ( ClassNotFoundException cnfex ) {
"Failed to load JDBC/ODBC driver." );
System.exit( 1 ); // terminate program
catch ( SQLException sqlex ) {
System.err.println( "Unable to connect" );

To decide on which database to use for a site is purely a business decision.. personally i feel that Oracle is better given its reliability and stability.


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us