Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't find acs.jdbc.Driver (MS Access driver)

Status
Not open for further replies.

ringd

Programmer
Jul 11, 2000
35
GB
Hello!

I have some code which is (attempting) to communicate with a local MS Access database. The following line of code throws exception java.lang.ClassNotFoundException: acs.jdbc.Driver ...

code line>>> Class.forName("acs.jdbc.Driver");

The only thing being imported is java.sql.*; .

Do I need to import something else; or download the driver in a jar from somewhere?

Any help would be appreciated.

Cheers,
Dave.

mailto:dave.ring@barclays.co.uk
 
Unless you downloaded a third party JDBC driver...the problem is in the following statement:

Code:
Class.forName("acs.jdbc.Driver");

With MS Access you have to you a JDBC ODBC bridge...see below:

Code:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

here is a sample code:

Code:
import java.sql.*;

public class DBSample 
{

	public static void main(String args[]) 
	{

		Connection con; // Create a connection object.
		
		
		try
		{


			// First, tell Java what driver to use and where to find it.
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			
			// Next, create a connection to your data source.
			// Specify that you are using the ODBC-JDBC Bridge.
			
			con = DriverManager.getConnection("jdbc:odbc:Temp");
			
			// Create an SQL statement.
			Statement stmt = con.createStatement();
			
			// Execute some SQL to create a table in your database.
			
			stmt.executeUpdate("SELECT * FROM SampleTable"); 
		}

	}
	catch(SQLException e)
	{

		System.out.println(e);
	}

}

Hope this helps.
 
Sorry I had a couple of errors in the sample code above...

Code:
import java.sql.*;

public class DBSample
{

	public static void main(String args[])
	{

		Connection con; // Create a connection object.


		try
		{


			// First, tell Java what driver to use and where to find it.
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

			// Next, create a connection to your data source.
			// Specify that you are using the ODBC-JDBC Bridge.

			con = DriverManager.getConnection("jdbc:odbc:Temp");

			// Create an SQL statement.
			Statement stmt = con.createStatement();

			// Execute some SQL to create a table in your database.

			stmt.executeUpdate("SELECT * FROM SampleTable");
		}

		catch(SQLException e)
		{

		System.out.println(e.);
		}
		catch (ClassNotFoundException c)
		{
			System.out.println(c);
		}
	}

}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top