Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing data from database and displaying in an Applet

 
Nithya Krishnan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,
I tried to access data from an access database and display it in textboxes in an applet.I have used the foll. code
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc dbc:dsn";
//dsn is a data source name created pointing to an access database
Connection con=DriverManager.getConnection(url);
When I use this in a Frame , I am able to display the result.
But if I try to put it in the init() method of an applet, SecurityException is getting thrown.The database is in the same directory as the java file.I even tried doing the connection in a separate thread. But always SecurityException is getting thrown. Can somebody tell me how to get this work?
How do we get to know what are all the drivers installed.
Thanks in Advance.
Nithya
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
You cannot access a database from an applet with type 1 (jdbcodbcDriver) driver.Use type 3 or 4.
Suneel
 
Nithya Krishnan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suneel,
Thanks for your reply.But what are types 3 or 4? From where can I get more info about the different drivers available?
Another thing about which I want info is this:
by using result.next(), I am able to move forward in the result set. How do I move backwards?ie how do I get a scrollable set?
Sorry if the questions are too basic.
Thanking in advance.
Nithya
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nithya
You can download for evaluation Type 4 drivers at this site.
You can use next() and previous() to go forward and back. With JDBC 2 API you can create resultset sets scrollable(JDK 2 and later versions).
Suneel
 
Nithya Krishnan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suneel,
ThankYou for the reply.I will download the driver from the link given and get back to you.Thank You once again.
Nithya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic