Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error using class.forName()

 
rogelio uribe
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mahesh Mamani
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai ,
U cant directly connect db to applet.there is some
problem with security.applets are highly secured. so try using servlets.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic