TrainBeaser for iPhone
The moose likes JDBC and the fly likes error using class.forName() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JDBC
Reply Bookmark "error using class.forName()" Watch "error using class.forName()" New topic
Author

error using class.forName()

rogelio uribe
Greenhorn

Joined: Aug 01, 2001
Posts: 14
Hi there:
I'm developing some application with an odbc link. I'm still testing it on a stand-alone PC and everything runs fine.
Once I change the regular class, for an applet I'm getting some errors, so that the programs fails. Here are some lines of code:
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.print("ClassNotFoundException: " + e.getMessage());
System.exit(1);
}

the line which includes forName("sun..."), is generating the error due to the argument enclosed in quotes, is prefixed by the path where i'm working on (the path where class file is located). I figured out going over the Java Console on my browser (IE). the error says:
com.ms.security.SecurityExceptionEx [method] Java.io.IOException: bad path: <my_current_working_directory>\sun\jdbc\odbc\JdbcodbcDriver.class
The thing is: why the program runs correctly as an application and fails as an applet?
The program is running on the same box where the dsn and database are defined.

Thanx for any help you can offer.
Rogelio


Roger
Mahesh Mamani
Ranch Hand

Joined: Jun 25, 2001
Posts: 110
Hi,
You cannot connect to DB directly from applets. There are security issues involved...
You have to code a servlet to connect to the DB and call this from the applet

Mahesh
bichu
Greenhorn

Joined: Mar 01, 2002
Posts: 1
Hai ,
U cant directly connect db to applet.there is some
problem with security.applets are highly secured. so try using servlets.


bichu......
 
 
subject: error using class.forName()
 
Threads others viewed
connection
Reading a Excel file using java programe
ClassCastException: sun.plugin.viewer.frame.IExplorerEmbeddedFrame to ViewerFrame
appletviewer
Access database using JDBC error
IntelliJ Java IDE