Hi, I’m trying to load the mysql connector jar file “on-the-fly” but getting a “no suitable driver” message when I try to get the connection.
I’ve got an applet sitting on my server along with the mysql jar file and when I run the applet from a web page with the jar named as an archive it all works fine. But, to shorten the load time I want to load the mysql jar later in the program while the user is paused reading some instructions. So here’s the code:
URL BURL=getCodeBase();
BURI = BURL.toURI();
URLClassLoader cl = null;
cl = new URLClassLoader(new URL[] {BURI.resolve(“mysql-connector-java-5.1.14-bin.jar”).toURL()});
Class.forName(“com.mysql.jdbc.Driver”, true, cl);
//Class.forName(“com.mysql.jdbc.Driver”, true, cl).newInsance();
//DriverManager.registerDriver(null);
Connection C=null;
C=DriverManager.getConnection(“jdbc:mysql://myserver.com/mydb”,un,pw);
The comment lines are among variations I’ve tried but I keep ending with the same problem when getConnection is called “no suitable driver found”.
Any ideas?
Thanks, Steve