The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2000

Advertisement

Advertisement

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.

Message:

can we use query in ms acess

Posted by shruti_rohatgi on April 10, 2001 at 12:55 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 ) {
> System.err.println(
> "Failed to load JDBC/ODBC driver." );
> cnfex.printStackTrace();
> System.exit( 1 ); // terminate program
> }
> catch ( SQLException sqlex ) {
> System.err.println( "Unable to connect" );
> sqlex.printStackTrace();
> }

> 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.






Replies:

Sponsored Links



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