Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

getting a start at jdbc mysql

Posted on 2000-04-13
4
Medium Priority
?
341 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 200 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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…
Suggested Courses

636 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