jdbc connection

  • Thread starter sangeeta chowdhary
  • Start date
S

sangeeta chowdhary

hey m writing program in java to connect it to mysql.
I have given driver name as
Class.forName("com.mysql.jdbc.Driver");
but i am getting ClassNotFoundException.
Please help me what shall i do.
 
M

Mike Schilling

sangeeta said:
hey m writing program in java to connect it to mysql.
I have given driver name as
Class.forName("com.mysql.jdbc.Driver");
but i am getting ClassNotFoundException.
Please help me what shall i do.

Ensure that the jar containing the class com.mysql.jdbc.Driver is in your
classpath.
 
S

sangeeta chowdhary

Ensure that the jar containing the class com.mysql.jdbc.Driver is in  your
classpath.

Thank you sir for your reply.
i have set user variable as mysql and value of this variable is xampp/
mysql/bin/mysql.exe
what else i need to do?
 
L

Lew

sangeeta said:
hey m writing program in java to connect it to mysql.
I have given driver name as
Class.forName("com.mysql.jdbc.Driver");
but i [sic] am getting ClassNotFoundException.
Please help me what shall i do.
Mike said:
Ensure that the jar containing the class com.mysql.jdbc.Driver is in your
classpath.

sangeeta said:
Thank you sir for your reply.
i have set user variable as mysql and value of this variable is xampp/
mysql/bin/mysql.exe

You do not need to do that.
what else i need to do?

You need to study about the Java classpath and JAR files. You need to
download the MySQL JDBC JAR file if you have not already done so. You need to
include that JAR file in the classpath for your Java program.

<http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html>
<http://java.sun.com/docs/books/tutorial/essential/environment/paths.html>
 
S

sangeeta chowdhary

sangeeta said:
hey m writing program in java to connect it to mysql.
I have given driver name as
Class.forName("com.mysql.jdbc.Driver");
but i [sic] am getting  ClassNotFoundException.
Please help me what shall i do.
Mike said:
Ensure that the jar containing the class com.mysql.jdbc.Driver is in  your
classpath.
sangeeta said:
Thank you sir for your reply.
i have set user variable as mysql and value of this variable is xampp/
mysql/bin/mysql.exe

You do not need to do that.
what else i need to do?

You need to study about the Java classpath and JAR files.  You need to
download the MySQL JDBC JAR file if you have not already done so.  You need to
include that JAR file in the classpath for your Java program.

<http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html>
<http://java.sun.com/docs/books/tutorial/essential/environment/paths.html>

Please tell me full procedure to sort out this problem.
i will be very thankful to you.
i have set classpath to mysql connector also.
still things are not working.
kindly help me please.
 
J

John B. Matthews

sangeeta chowdhary said:
sangeeta said:
hey m writing program in java to connect it to mysql.
I have given driver name as
Class.forName("com.mysql.jdbc.Driver");
but i [sic] am getting  ClassNotFoundException.
Please help me what shall i do.
Mike said:
Ensure that the jar containing the class com.mysql.jdbc.Driver
is in  your classpath.
sangeeta said:
Thank you sir for your reply.
i have set user variable as mysql and value of this variable is
xampp/ mysql/bin/mysql.exe

You do not need to do that.
what else i need to do?

You need to study about the Java classpath and JAR files.  You need
to download the MySQL JDBC JAR file if you have not already done
so.  You need to include that JAR file in the classpath for your
Java program.

<http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html>
<http://java.sun.com/docs/books/tutorial/essential/environment/paths.html>

Please tell me full procedure to sort out this problem. i will be
very thankful to you. i have set classpath to mysql connector also.
still things are not working. kindly help me please.

After reading the tutorial, try something like this, adapted from the
documentation included with the driver:

public class LoadDriver {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
    }
}

On my platform, I'd do this:

$ ls mysql-connector-java-5.1.12-bin.jar
mysql-connector-java-5.1.12-bin.jar
$ javac LoadDriver.java
$ java -cp mysql-connector-java-5.1.12-bin.jar:. LoadDriver

If you're using Windows, you need to use ';' as the path separator, as
discussed in the second link provided by Lew.
 
L

Lew

sangeeta said:
i [sic] have set user variable as mysql and value of this variable is xampp/
mysql/bin/mysql.exe
You do not need to do that.
sangeeta said:
what else i [sic] need to do?
Lew said:
You need to study about the Java classpath and JAR files. You need to
download the MySQL JDBC JAR file if you have not already done so. You need to
include that JAR file in the classpath for your Java program.

<http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html>
<http://java.sun.com/docs/books/tutorial/essential/environment/paths.html>

sangeeta said:
Please tell me full procedure to sort out this problem.

We already did. Read the links.
i [sic] will be very thankful to you.

Really? Why not already?
i [sic] have set classpath to mysql [sic] connector also.
still things are not working.

What *precisely* did you do? Copy and paste (!) your commands, please.
Describe *exactly* what "not working" means - what did you do, what did you
expect, and what happened instead? Please be specific. Cite exact error
messages if you got any. Vague hand-waving does not empower useful answers.

Have you read the links?

Don't demand that we do all your work for you when you don't even provide
enough information to hint at what your difficulty is, haven't used the
information already provided, and haven't even expressed gratitude for the
help so far. This is a discussion group, not a help desk or unpaid outsource
software shop.
 
S

sangeeta chowdhary

sangeeta said:
i [sic] have set user variable as mysql and value of this variable is xampp/
mysql/bin/mysql.exe
Lew said:
You do not need to do that.
sangeeta said:
what else i [sic] need to do?
Lew said:
You need to study about the Java classpath and JAR files.  You need to
download the MySQL JDBC JAR file if you have not already done so.  You need to
include that JAR file in the classpath for your Java program.
<http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html>
<http://java.sun.com/docs/books/tutorial/essential/environment/paths.html>
sangeeta said:
Please tell me full procedure to sort out this problem.

We already did.  Read the links.
i [sic] will be very thankful to you.

Really?  Why not already?
i [sic] have set classpath to mysql [sic] connector also.
still things are not working.

What *precisely* did you do?  Copy and paste (!) your commands, please.
Describe *exactly* what "not working" means - what did you do, what did you
expect, and what happened instead?  Please be specific.  Cite exact error
messages if you got any.  Vague hand-waving does not empower useful answers.

Have you read the links?

Don't demand that we do all your work for you when you don't even provide
enough information to hint at what your difficulty is, haven't used the
information already provided, and haven't even expressed gratitude for the
help so far.  This is a discussion group, not a help desk or unpaid outsource
software shop.

Thank you sir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,117
Latest member
Matilda564
Top