aspose file tools*
The moose likes Applets and the fly likes Accessing data from database and displaying in an Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Accessing data from database and displaying in an Applet" Watch "Accessing data from database and displaying in an Applet" New topic
Author

Accessing data from database and displaying in an Applet

Nithya Krishnan
Greenhorn

Joined: Dec 06, 2000
Posts: 5
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

Joined: Nov 26, 2000
Posts: 202
Hi
You cannot access a database from an applet with type 1 (jdbcodbcDriver) driver.Use type 3 or 4.
Suneel


Suneel
Nithya Krishnan
Greenhorn

Joined: Dec 06, 2000
Posts: 5
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

Joined: Nov 26, 2000
Posts: 202
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

Joined: Dec 06, 2000
Posts: 5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing data from database and displaying in an Applet