Problem with JDBC-ODBC connection to MS Access 2000  
Author Message
lmclaus





PostPosted: 2003-11-27 2:18:00 Top

java-programmer, Problem with JDBC-ODBC connection to MS Access 2000 I am trying to use JDBC-ODBC bridge to connect to a Access 2000
database on a Windows 2000 machine. I have set up
the database using the Data Sources utility in Windows 2000. I am
using the Java(TM) 2 SDK, Standard Edition
Version 1.4.2_01. The code snippet from an example I found is:

import java.sql.*;
import javax.swing.JOptionPane;

public class BookDB{
private static Connection connection;
private static Statement scrollStatement;
private static ResultSet books;

public static void connect() throws ClassNotFoundException,
SQLException {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:MurachBooks";
String user = "Admin";
String password = "";
connection = DriverManager.getConnection(url, user, password);
}

When I complie I get the following error:

BookDB.java [10:1] cannot resolve symbol
symbol : method forName (java.lang.String)
location: class Class
try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
^
1 error
Errors compiling BookDB.

I have looked at all of the possible sources of information I can
think of to find an answer to my problem.
 
Stefan Siegl





PostPosted: 2003-11-28 5:11:00 Top

java-programmer >> Problem with JDBC-ODBC connection to MS Access 2000 I do not see any errors in the code. The same code will work fine for me
(there is no compile time error). Are you sure that you did not mess up
with the standard classpath?

lmclaus wrote:

> I am trying to use JDBC-ODBC bridge to connect to a Access 2000
> database on a Windows 2000 machine. I have set up
> the database using the Data Sources utility in Windows 2000. I am
> using the Java(TM) 2 SDK, Standard Edition
> Version 1.4.2_01. The code snippet from an example I found is:
>
> import java.sql.*;
> import javax.swing.JOptionPane;
>
> public class BookDB{
> private static Connection connection;
> private static Statement scrollStatement;
> private static ResultSet books;
>
> public static void connect() throws ClassNotFoundException,
> SQLException {
>
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> String url = "jdbc:odbc:MurachBooks";
> String user = "Admin";
> String password = "";
> connection = DriverManager.getConnection(url, user, password);
> }
>
> When I complie I get the following error:
>
> BookDB.java [10:1] cannot resolve symbol
> symbol : method forName (java.lang.String)
> location: class Class
> try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> ^
> 1 error
> Errors compiling BookDB.
>
> I have looked at all of the possible sources of information I can
> think of to find an answer to my problem.

 
lmclaus





PostPosted: 2003-11-28 21:52:00 Top

java-programmer >> Problem with JDBC-ODBC connection to MS Access 2000 Stefan Siegl <email***@***.com> wrote in message news:<bq5p9c$1tpcbp$email***@***.com>...
> I do not see any errors in the code. The same code will work fine for me
> (there is no compile time error). Are you sure that you did not mess up
> with the standard classpath?
>
> lmclaus wrote:
>
> > I am trying to use JDBC-ODBC bridge to connect to a Access 2000
> > database on a Windows 2000 machine. I have set up
> > the database using the Data Sources utility in Windows 2000. I am
> > using the Java(TM) 2 SDK, Standard Edition
> > Version 1.4.2_01. The code snippet from an example I found is:
> >
> > import java.sql.*;
> > import javax.swing.JOptionPane;
> >
> > public class BookDB{
> > private static Connection connection;
> > private static Statement scrollStatement;
> > private static ResultSet books;
> >
> > public static void connect() throws ClassNotFoundException,
> > SQLException {
> >
> > Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> > String url = "jdbc:odbc:MurachBooks";
> > String user = "Admin";
> > String password = "";
> > connection = DriverManager.getConnection(url, user, password);
> > }
> >
> > When I complie I get the following error:
> >
> > BookDB.java [10:1] cannot resolve symbol
> > symbol : method forName (java.lang.String)
> > location: class Class
> > try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> > ^
> > 1 error
> > Errors compiling BookDB.
> >
> > I have looked at all of the possible sources of information I can
> > think of to find an answer to my problem.


The classpath variable setting certainly may be a problem. I have been
confused by the instructions I have read on what I need to define for
various path settings and whether they need to be in a User or System
path variable.
 
 
Bjorn Abelli





PostPosted: 2003-11-28 23:03:00 Top

java-programmer >> Problem with JDBC-ODBC connection to MS Access 2000
"lmclaus" wrote...

> > > I am trying to use JDBC-ODBC bridge to connect to a Access 2000
> > > database on a Windows 2000 machine. I have set up
> > > the database using the Data Sources utility in Windows 2000. I am
> > > using the Java(TM) 2 SDK, Standard Edition
> > > Version 1.4.2_01. The code snippet from an example I found is:
>
> The classpath variable setting certainly may be a problem. I have been
> confused by the instructions I have read on what I need to define for
> various path settings and whether they need to be in a User or System
> path variable.

With that configuration you shouldn't need to have the classpath as an
environment variable at all.

// Bjorn A


 
 
Stefan Siegl





PostPosted: 2003-11-29 9:46:00 Top

java-programmer >> Problem with JDBC-ODBC connection to MS Access 2000

lmclaus wrote:
> Stefan Siegl <email***@***.com> wrote in message news:<bq5p9c$1tpcbp$email***@***.com>...
>
>>I do not see any errors in the code. The same code will work fine for me
>>(there is no compile time error). Are you sure that you did not mess up
>>with the standard classpath?
>>
>>lmclaus wrote:
>>
>>
>>>I am trying to use JDBC-ODBC bridge to connect to a Access 2000
>>>database on a Windows 2000 machine. I have set up
>>>the database using the Data Sources utility in Windows 2000. I am
>>>using the Java(TM) 2 SDK, Standard Edition
>>>Version 1.4.2_01. The code snippet from an example I found is:
>>>
>>>import java.sql.*;
>>>import javax.swing.JOptionPane;
>>>
>>>public class BookDB{
>>> private static Connection connection;
>>> private static Statement scrollStatement;
>>> private static ResultSet books;
>>>
>>> public static void connect() throws ClassNotFoundException,
>>>SQLException {
>>>
>>> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>>> String url = "jdbc:odbc:MurachBooks";
>>> String user = "Admin";
>>> String password = "";
>>> connection = DriverManager.getConnection(url, user, password);
>>> }
>>>
>>>When I complie I get the following error:
>>>
>>>BookDB.java [10:1] cannot resolve symbol
>>>symbol : method forName (java.lang.String)
>>>location: class Class
>>> try {Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>>> ^
>>>1 error
>>>Errors compiling BookDB.
>>>
>>>I have looked at all of the possible sources of information I can
>>>think of to find an answer to my problem.
>
>
>
> The classpath variable setting certainly may be a problem. I have been
> confused by the instructions I have read on what I need to define for
> various path settings and whether they need to be in a User or System
> path variable.

If you do not change the bootstrap ClassLoader of Java then all the
needed classes should be loaded automatically be the JVM. If you are not
completely sure if you change it, perhaps you can provide the command
you use to start your program.