954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

problem with database Connection in applet

Developing an applet , which queries information from database and displays.

Database used is sqlite.
Application Envi:: Application runs on the local machine and the database file is present locally. The application is run inside Web browser and not in the appletviewer.

Due to security restrictions, applet doesn't allow application to read/write files from other directories. So the database file and the application class files are maintained in the same folder/directory.

I am able to read normal text file from the applet, provided the files are in the same directory where class files are.
But the problem i encounter is, to query from database a connection needs to be established, since sqlite uses file i am unable to establish a connection.

The exception I receive when I try to connect database using the relative path,
java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)

Part of Code:
try{
Class.forName("org.sqlite.JDBC");
Connection con = DriverManager.getConnection("jdbc:sqlite:/dbFile");
Statement stmt = con.createStatement();
} catch(Exception e){
e.printStackTrace();
}
If i specify the absolute path of file i get
java.security.AccessControlException: access denied (java.io.FilePermission g:\project\ read)

Part of Code:
try{
Class.forName("org.sqlite.JDBC");
Connection con = DriverManager.getConnection("jdbc:sqlite:/g:/project/dbFile");
Statement stmt = con.createStatement();
} catch(Exception e){
e.printStackTrace();
}


Looking for a solution to this problem.
Thanks in advance.

gowrishg
Newbie Poster
3 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 
Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 
http://www.oracle.com/technology/oramag/code/tips2004/031504.html


I am afraid that i have mentioned, that my application IS NOT running via appletviewer but uses web browser. The above link gives procedure to run applet using appletviewer, which is different from running application in web browser.

gowrishg
Newbie Poster
3 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You