applet and jdbc
hello there!
have anyone some experience with applet/jdbc developpement?
I have a simple application with jdbc that only connects with database to check if it is possible. That plain java application works fine but when I copy/paste the part that is responsible for establishing connection with database to my applet application it produces an error! I 'm using mysql 5 and jdbc driver from mysql site. I'm really pressed with this project ahave no idea why it is not working .thus giving you some duke points for helping me out. thanks!! :)
my applet code:
"
import java.awt.*;
import java.applet.*;
import java.sql.*;
public class TestJDBC extends Applet {
Connection conn = null;
public void init() {
try
{
String userName = "root";
String password = "pawelo";
String url = "jdbc:mysql://localhost:3306/DBTest";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e)
{
System.err.println ("Cannot connect to database server"+e.getMessage());
}
finally
{
if (conn != null){
try{
conn.close ();
System.out.println ("Database connection terminated");
}catch (Exception e) {
}
}
}
}
public void paint(Graphics g) {
g.drawString("Welcome to Java!!", 50, 60 );
}
}
"
and the error produced :
java.lang.ExceptionInInitializerError
at com.mysql.jdbc.Connection.<init>(Connection.java:1175)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at TestJDBC.init(TestJDBC.java:17)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Unable to initialize character set mapping tables
at com.mysql.jdbc.CharsetMapping.<clinit>(CharsetMapping.java:73)
... 7 more
Exception in thread "thread applet-TestJDBC.class" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

