user1467196
user1467196

Reputation: 43

JDBC mysql Wamp

I've downloaded the MySQL JDBC driver. In my Eclipsoe project I modified the build path so that the mysql-connector-java.bin.jar is there and I can call functions from that jar.

When run the application from Eclipse, everything is fine and a proper connection to the MySql db is made.

However, when I upload and run the application on my WampServer,

        try {

            Class.forName("com.mysql.jdbc.Driver");

        } catch (ClassNotFoundException e) {

            System.out.println("Where is your MySQL JDBC Driver?");
            e.printStackTrace();
            addItem("Class not found");
            return;

        }

it seems to not go into the ClassNotFoundExeption block of the try-catch.

Any insight as to what I'm doing wrong?

Upvotes: 0

Views: 1416

Answers (2)

Gaurav Srivastav
Gaurav Srivastav

Reputation: 2551

If you are using Java Project rather web application you should build path for the mysql jar.

Steps for Java project 1)Right click on your java project and choose preferences. 2)In window dialog click on Java build path and then click on Libraries tab. 3)Now click on add external jars for addding mysql jar.

For web application you need to put the jar to lib directory.

Upvotes: 0

kosa
kosa

Reputation: 66637

You have jar in build path, but it seems you are missing it in runtime. If it is web application, add mysql jar to lib folder of web application.

Upvotes: 1

Related Questions