aspose file tools*
The moose likes JDBC and the fly likes I've tried everything Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "I Watch "I New topic
Author

I've tried everything

ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
I've tried everything. I can't get an applet to connect to an Access Database using the JDBC-ODBC driver.
I've got all the data sources setup in ODBC, but can't seem to connect, instead I recieve this connection:
java.security.AccessControlException: access denied (java.lan.RuntimePermission accessClassInPackage.sun.jdbc)
Has anyone seen this error before? I've commented out code such that I think I have found the line that is causing the problem at runtime.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
I have a comment just before the try block that the above line is in that outputs the message "run ClassforName" to the command prompt.
Then I have the first line of the catch block output "ClassforName failed".
The output I get at the command prompt is:
run ClassforName
ClassforName failed.
The applet output is the error mentioned above.
HELP ME!!!
Ryan


Ryan Headley<br /><a href="http://www.sudovi.com" target="_blank" rel="nofollow">http://www.sudovi.com</a>
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
An applet can not connect to any server other than the one it came from. Unless the database is on the web server, the browser will not permit the applet to connect to the database. The solution is to set up a servlet on the web server and use the servlet as a proxy. Or get a security certificate for the applet.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
this file is not on the server...all this is local.
the database is on my Hard Drive.
I don't think the applet is even making to the point where it tries to connect. The code is direclty from Suns JDBC tutorial with the name changes for my Data source name, driver info, and url.
Ryan
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
Ryan,
Even if everything is local, I don't think you can instantiate a class outside the applet. Can you give us the link from the JAVA tutorial? I would be surprise if this example is using an applet. It might be using it as an application.
I would have to agree with the post by Thomas.
-Peter
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
Originally posted by ryan headley:
Well,
Taking the info from Paul, I converted to a standard Console based app and I at least connect and get my data returned. Here is the link to the JDBC tutorial, specifically to the code...
http://java.sun.com/docs/books/tutorial/jdbc/basics/applet.html
[This message has been edited by ryan headley (edited January 08, 2001).]
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
I stand corrected. The tutorial is using an applet. The last paragraph of your link to the tutorial says that using JDBC inside the applet should be okay. Hmm...
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
Ryan,
Have you seen the JDBC FAQ from SUN?
Here's one you might be interested:
3. Can the JDBC-ODBC Bridge be used with applets?
Use of the JDBC-ODBC bridge from an untrusted applet running in a browser, such as Netscape Navigator, isn't allowed. The JDBC-ODBC bridge doesn't allow untrusted code to call it for security reasons. This is good because it means that an untrusted applet that is downloaded by the browser can't circumvent Java security by calling ODBC. Remember that ODBC is native code, so once ODBC is called, the Java programming language can't guarantee that a security violation won't occur. On the other hand, Pure Java JDBC drivers work well with applets. They are fully downloadable and do not require any client-side configuration.
Finally, we would like to note that it is possible to use the JDBC-ODBC bridge with applets that will be run in appletviewer since appletviewer assumes that applets are trusted. It is also possible to use the JDBC-ODBC bridge with applets that are run in the HotJavaTM browser (available from Java Software), since HotJava provides an option to turn off applet security. In general, it is dangerous to turn applet security off, but it may be appropriate in certain controlled situations, such as for applets that will only be used in a secure intranet environment. Remember to exercise caution if you choose this option, and use an all-Java JDBC driver whenever possible to avoid security problems.
-Peter
Ps. Still looking at your program.
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
where'd ya find that one?
That would have helped my understanding at least. However, it says it should work in the appletviewer, which I can understand. I am just completely stumped about why its not working in appletviewer....thanx for your time! =)
Ryan
P.S. Duh! You included the link....silly me...
[This message has been edited by ryan headley (edited January 09, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I've tried everything