smartin7
asked on
Simple SQL Applet
Hey all, I'm trying to write my first SQL applet which connects to an Access database. I'm just trying to get the framework of this to work so I can experiement with it later.
I am using an ODBC bridge driver.
Here is my error:
java.security.AccessContro lException : access denied (java.lang.RuntimePermissi
accessClassInPackage.sun.j dbc.odbc)
at java.security.AccessContro lContext.c heckPermis sion(Acces sControlCo n
xt.java:270)
at java.security.AccessContro ller.check Permission (AccessCon troller.ja v
401)
at java.lang.SecurityManager. checkPermi ssion(Secu rityManage r.java:542 )
at java.lang.SecurityManager. checkPacka geAccess(S ecurityMan ager.java: 1
3)
at sun.applet.AppletSecurity. checkPacka geAccess(A ppletSecur ity.java:1 6
at sun.applet.AppletClassLoad er.loadCla ss(AppletC lassLoader .java:109)
at java.lang.ClassLoader.load Class(Clas sLoader.ja va:262)
at java.lang.ClassLoader.load ClassInter nal(ClassL oader.java :322)
at java.lang.Class.forName0(N ative Method)
at java.lang.Class.forName(Cl ass.java:1 30)
at SqlTest.init(SqlTest.java: 39)
at sun.applet.AppletPanel.run (AppletPan el.java:34 1)
at java.lang.Thread.run(Threa d.java:536 )
Here is my Applet: VERY SIMPLE -- Dont laugh:
/*
* @(#)SqlTest.java 1.0 02/04/10
*
* You can modify the template of this file in the
* directory ..\JCreator\Templates\Temp late_2\Pro ject_Name. java
*
* You can also create your own project template by making a new
* folder in the directory ..\JCreator\Template\. Use the other
* templates as examples.
*
*/
import java.awt.*;
import java.applet.*;
import java.sql.*;
import javax.swing.*;
public class SqlTest extends JApplet {
String fName = new String();
String lName = new String();
public void init() {
String url = "jdbc:odbc:dsnTest";
String sqlString = "Select * Customer";
ResultSet rs;
Statement strSQL;
Connection con;
try
{
//create instance of the driver
Class.forName("sun.jdbc.od bc.JdbcOdb cDriver");
//creat the connection
con = DriverManager.getConnectio n(url);
//make sql statment
strSQL = con.createStatement();
rs = strSQL.executeQuery(sqlStr ing);
while(rs.next())
{
fName = rs.getString("First Name");
lName = rs.getString("Last Name");
if(fName == null)
System.out.println("NULL!! ");
if(lName == null)
System.out.println("Last name is null");
}
}
//catch all exceptions
catch(Exception e)
{
e.printStackTrace();
return;
}
}
public void paint(Graphics g)
{
g.drawString("First Name: " + fName, 50, 60);
}
}
I am using an ODBC bridge driver.
Here is my error:
java.security.AccessContro
accessClassInPackage.sun.j
at java.security.AccessContro
xt.java:270)
at java.security.AccessContro
401)
at java.lang.SecurityManager.
at java.lang.SecurityManager.
3)
at sun.applet.AppletSecurity.
at sun.applet.AppletClassLoad
at java.lang.ClassLoader.load
at java.lang.ClassLoader.load
at java.lang.Class.forName0(N
at java.lang.Class.forName(Cl
at SqlTest.init(SqlTest.java:
at sun.applet.AppletPanel.run
at java.lang.Thread.run(Threa
Here is my Applet: VERY SIMPLE -- Dont laugh:
/*
* @(#)SqlTest.java 1.0 02/04/10
*
* You can modify the template of this file in the
* directory ..\JCreator\Templates\Temp
*
* You can also create your own project template by making a new
* folder in the directory ..\JCreator\Template\. Use the other
* templates as examples.
*
*/
import java.awt.*;
import java.applet.*;
import java.sql.*;
import javax.swing.*;
public class SqlTest extends JApplet {
String fName = new String();
String lName = new String();
public void init() {
String url = "jdbc:odbc:dsnTest";
String sqlString = "Select * Customer";
ResultSet rs;
Statement strSQL;
Connection con;
try
{
//create instance of the driver
Class.forName("sun.jdbc.od
//creat the connection
con = DriverManager.getConnectio
//make sql statment
strSQL = con.createStatement();
rs = strSQL.executeQuery(sqlStr
while(rs.next())
{
fName = rs.getString("First Name");
lName = rs.getString("Last Name");
if(fName == null)
System.out.println("NULL!!
if(lName == null)
System.out.println("Last name is null");
}
}
//catch all exceptions
catch(Exception e)
{
e.printStackTrace();
return;
}
}
public void paint(Graphics g)
{
g.drawString("First Name: " + fName, 50, 60);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Girionis,
Thanks for the information, thats exactly what I need. It appears I need to create a policy file. This is a great link. Thanks again!
-Scott
Thanks for the information, thats exactly what I need. It appears I need to create a policy file. This is a great link. Thanks again!
-Scott
No problem. Thank you for the points :-)
Hope it helps.