Solved

getting a start at jdbc mysql

Posted on 2000-04-13
4
334 Views
Last Modified: 2012-06-27
I am useing jdk1.1.8
and mm.mysql.jdbc-1.2c

I want to this code

import java.sql.*;

public class ConnectCoffeesMM {
    public static void main(String args[]) {

        // The URL that will connect to TECFA's MySQL server
        // Syntax: jdbc:TYPE:machine:port/DB_NAME
        String url = "jdbc:mysql://serka.sawbos.jive:3306/CD";

        // INSTALL/load the Driver (Vendor specific Code)
        try {
            Class.forName("org.gjt.mm.mysql.Driver");

        } catch(java.lang.ClassNotFoundException e) {
            System.err.print("ClassNotFoundException: ");
            System.err.println(e.getMessage());
        }

        try {
            Connection con;
            Statement stmt;
           
            // Establish Connection to the database at URL with usename and password
            con = DriverManager.getConnection(url, "root", "*******");
            System.out.println ("Hello, Connection to the CD table worked");
            con.close();

        } catch(SQLException ex) {
            System.err.println("==> SQLException: ");
              while (ex != null) {
                  System.out.println("Message:   " + ex.getMessage ());
                  System.out.println("SQLState:  " + ex.getSQLState ());
                  System.out.println("ErrorCode: " + ex.getErrorCode ());
                  ex = ex.getNextException();
                  System.out.println("");
              }
        }
    }
}

all goes well with javac
but java ConnectCoffeesMM gives me
ClassNotFoundException: org.gjt.mm.mysql.Driver
==> SQLException:
Message:   No suitable driver
SQLState:  08001
ErrorCode: 0


So I have not got it my CLASSPATH
but setevn CLASSPATH /usr/local/mm.mysql.jdbc-1.2c:$CLASSPATH
gets me nothing, now I am told
Can't find class ConnectCoffeesMM
so the $CLASSPATH must be wrong what shoud it be?? I am baffeled

Thanks for any help.
0
Comment
Question by:thedogeater
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Accepted Solution

by:
fmaritato earned 100 total points
ID: 2714142
you have to put the location of the jar file in your classpath:

setenv CLASSPATH /usr/local/mm.mysql.jdbc/mysql_comp.jar:${CLASSPATH}

0
 
LVL 3

Expert Comment

by:terajiv
ID: 2714732
Make Sure that Proper Driver is Loaded on your System. Then try running the Application...

And Ofcourse Classpath is also Important.

All the Best

Rajiv
0
 

Author Comment

by:thedogeater
ID: 2719515
Thans for teh responces I got it to work in the end
fmaritato was right about the CLASSPATH
but the one he or she gave did not work
anyhow  Iwill give teh points.
0
 

Expert Comment

by:stanleyhuen
ID: 3399371
hi thedogeater,

i have same problem as you,

ClassNotFoundException: com/imaginary/sql/msql/MsqlDriver
==> SQLException:
Message:   driver not found: jdbc:mysql://www.hketutor.com/hketutor
SQLState:  null
ErrorCode: 0


how can you solve your problem?
can you explain it in details to me?
i can give you 100 points.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iterator/ListIterator approach 17 66
glassfish admin console 1 47
junit example issue 2 54
Where to place postgres JDBC driver jar on tomcat 8 70
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question