aspose file tools*
The moose likes JDBC and the fly likes connecting to MS Access 97 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "connecting to MS Access 97" Watch "connecting to MS Access 97" New topic
Author

connecting to MS Access 97

ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
I was working thru the JDBC tutorial on java.sun.com. I created the tables that they talk bout inside of Access 97. I've added my data source and ODBC stuff to my windows NT environment.
I grabbed the code from the website, modified what I thought they needed me to modify, it compiled but when I run it i get the following as an error:
Can't find Database Driver class: java.security.AccessControlException: access denied (java.lan.RuntimePermission accessClassInPackage.sun.jdbc)
I know the first part of the message is just a string in the beginning of the catch statement but the rest of it I don't follow.
I am loading sun.jdbc.odbc.JdbcOdbcDriver as my ODBC JDBC_ODBC Bridge.
Does this path come automatically with the JDK or is there a separate package I need to d/l.
Thanx,
Ryan

Ryan Headley<br /><a href="http://www.sudovi.com" target="_blank" rel="nofollow">http://www.sudovi.com</a>
Frank Wang
Greenhorn

Joined: Aug 18, 2000
Posts: 25
Hi, Ryan, maybe you have got it already.
Just like Paul Sun's answer to my question, maybe you need to specify the data source name in the url in your coding properly.
When you load the bridge from JDK, you needn't do anything more with other package. And the driver is in the Access which provides it originally.
Frank W.
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
Maybe that is where I am screwing up...you said load the bridge from JDK:
Is there something special I need to do here??
i've narrowed it down to this this section of code...(so far)
public void run() {
String url = "jdbc dbc:testdb";
String query = "select COF_NAME, PRICE from COFFEES";
//System.out.println("run Class.forName");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(Exception ex) {
//System.out.println("classforname failure");
setError("Can't find Database driver class: " + ex);
return;
}
thru troubleshooting (see commented out lines above) I have determined that the line that is causing the problem is in the try block: ClassforName("sun.jdbc.odbc.JdbcOdbcDriver");
my connection code is:
Connection con = DriverManager.getConnection ("jdbc dbc:testdb", "", "");
the name of my database is testdb and was created in Access 97.
Ryan
Frank Wang
Greenhorn

Joined: Aug 18, 2000
Posts: 25
The trick is you need to specify the name "testdb" (which needs be designated in the connection URL) in ODBC data source manager, while the database you have created in Access (for example, the testdb.mdb in Access 97 in your hard drive) is required to be selected there.
The connection code:
Connection con = DriverManager.getConnection ("jdbc dbc:testdb", "", "");
should be right.
Have fun.
Frank W.

ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
on NT4, insdie ODBC Administrator i have the Access 97 driver added. the Data source name is testdb, the database itself is name testdb.mdb and is located on my hard drive. I have it set so that now password or userid is required to access it.
hmmmmm,
I'll keep playin.
 
 
subject: connecting to MS Access 97