• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

problem with mysql connecton!

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi folks,
i downloaded mm.mysql-2.0.14-you-must-unjar-me and put it in CLASSPATH. trying to make a connection to mysql from a servlet. when i execute servlet, gives me the following error;
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver .could you please give me a hints where did i go wrong?
thanks.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd suspect that your classpath isn't set correctly. Take a look at the instructions at the top of the JDBC assignments in The JavaRanch Cattle Drive.
[ April 09, 2003: Message edited by: Dirk Schreckmann ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, if I recall correctly, you have to unjar the file with the words "unjar-me" as part of the name and it's the "mm.mysql-2.0.14-bin.jar" file that should be in your classpath.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FYI - mm.mysql is pretty old. It was maintained by Mark Mathews who was then hired by the MySQL Team of developers to continue production on the Driver which is now called Connector/J. Not that this will solve your problem, but you will get more functionallity out of the newer driver. Information and Download can be found here
 
Himal Chuli
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys for your prompt help but i still don't seem to get it working. As Dirk mention, i unjar and put it into CLASSPATH, still it does not find the org.gjt.mm.mysql.Driver. i even tried using Connector/j as Gregg mentioned, still the problem is same. i am tired but i need to get it working. wonder if i am doing something wrong here. i don't know why it does not work. please give me help here.
thanks.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mentioned that this is a problem when "executing" a servlet. So, this must be a runtime problem.
The JAR file needs to be "locateable" by your Servlet container. So, you probably want to add the JAR file to the lib folder of your web application. Or, for example, with a default installation of Tomcat, you could add it to the common/lib folder and then it would be accessible to any web app running on Tomcat.
The Cattle Drive explains doing this same thing with Orion Server.
Any luck?
 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I downloaded the Development version of the MySQL. Nonetheless, it should work for you.
1. download the Connector/J (mysql-connector-java-3.1.0-alpha.zip).
Unzip the outer file into your root directory (C:\).
2. at the very beginning, type:
C:\> C:\mysql\bin\mysqld-nt --standalone
to start mysql server
3. and when you make changes you should compile java files again

4. Using the JDBC Driver
In order to use the JDBC driver, you just need
to put it on your classpath, OR installing it
as a Java extension library.
4.1. to put it on the classpath:
WINDOWS:
set classpath=.;C:\mysql-connector-java-3.1.0-alpha\mysql-connector-java-3.1.0-alpha-bin.jar;%classpath%
(of course, you'll need to change the folders to the folder you put the JAR into)
4.2. if you put it in your jre/lib/ext folder of your JDK/JRE, the JDBC Driver will also be found automatically.

4.3. alternatively, run the program this way:
java -classpath C:\mysql-connector-java-3.1.0-alpha\mysql-connector-java-3.1.0-alpha-bin.jar; TestServlet localhost test
where TestServlet is the name of the Java program and test is the name of the database.
4.3. The driver is mysql-connector-java-3.1.0-alpha-bin.jar, placed it in
C:\jakarta-tomcat-4.1.18-LE-jdk14\common\lib directory
5. prepare the web.xml file for running Servlets
6. Compile the test program:

javac -d C:\jakarta-tomcat-4.1.18-LE-jdk14/webapps/ROOT/WEB-INF/classes TestServlet.java
7. Run it by the following command:

start the Tomcat and
http://localhost:8080/servlet/TestServlet

Here is the code for the TestServlet.java

[ April 09, 2003: Message edited by: JiaPei Jen ]
[ April 09, 2003: Message edited by: JiaPei Jen ]
[ April 09, 2003: Message edited by: JiaPei Jen ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those look like decent step-by-step instructions. Thanks JiaPei Jen.
I would suggest using a stable version of ConnectorJ, instead of that scary alpha stuff.
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic