PDA

View Full Version : Applet updating a database, exception handling help


ashley.morgan
11-01-2010, 08:37 PM
I am writing an applet that connects to MSAccess. I recieved runtime permission errors and resolved them and now am getting a SQL exception saying it can't find my dsn.


public void updater(String str1, String str2, String str3, String str4)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (ODBC dsn)};");
Statement s = con.createStatement();
s.execute("insert into StudentChoices (CLASS1, CLASS2, CLASS3, CLASS4) VALUES('" + str1 +"', '"+ str2 +"', '"+ str3 +"','"+ str4+"')");
s.execute("insert into StudentChoices (CLASS1, CLASS2, CLASS3, CLASS4) VALUES('BLANK', 'BLANK', 'BLANK', 'BLANK'");
System.out.println("It should have worked");
}
catch (Exception e)
{
System.out.println("Error: " + e);
}
}

To open the appletI have to call it throught the command prompt with the policy file


C:\Student Input for Scheduler>appletviewer -J-Djava.security.policy=PolicyFile.txt sampleApplet.html


To fix the permission exceptions I had to take out the specific DSN and now I'm getting this exception

Error: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified


Any suggestions?