Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

J2ME and MySQL connection

Status
Not open for further replies.

weemien23

Programmer
Nov 24, 2003
10
NL
Hi,

I want to write an application with Java(J2ME) for my blackberry devices. I want to connect that application with a mysql database and I'm using Sun ONE 5 micro edition. The problem is it couln't find the JDBC drivers while it is trying to connect.
Always get the error.
"java.lang.ClassNotFoundException: com.mysql.jdbc.Driver"

The problem is here:
{..
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
...
}
I already have the JDBC driver from MySQL,but I tried every configuration possible.
Can someone help me with this.

WeeMien


 
is this a J2ME-specific issue you're having? Meaning, have you been able to get this to work with J2SE etc, but are just now having problems with J2ME? or is this your first time trying JDBC out?<br><br>are you sure about the driver class? I always used org.gjt.mm.mysql.Driver... make sure your driver is there, and check the actual class name of your driver. <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
I have program before with JDBC. A normal JAVA application has no problem connecting to MYSQL, but the one I'm making with J2ME does.
I don't know how to configure the SUN ONE to include the drivers:(
 
but are you sure you have the correct driver to begin with, because i've always used a different driver with mysql... <p>Liam Morley<br><A HREF="mailto:"></A><br>&quot;light the deep, and bring silence to the world.<br>light the world, and bring depth to the silence.&quot;
 
I'm not sure about the drivers..it could be that J2ME use different drivers to access the mysql database than J2SE..
If so, I have no idea which one, because I could not find any other JDBC drivers.
 
Liam,

A while ago MySQL changed the'r driver package/class from

org.gjt.mm.mysql.Driver

to

com.mysql.jdbc.Driver

Now if you call org.gjt.mm.mysql.Driver, it just calls com.mysql.jdbc.Driver - and exists only for backwards compatibility.


WeeMien,

This is not, imho, a J2ME specific problem. The error you are seeing is just because the jar file that contains com.mysql.jdbc.Driver is not on your J2ME CLASSPATH - now how this differs from j2se I don't know - but you need to include the mysql jar on your CLASSPATH.


 
I already have the driver on the classpath.

set CLASSPATH=C:\j2sdk1.4.1_06\jre\lib\ext\mysql-connector-java-3.0.9-stable-bin.jar;.

WeeMien
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top