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.