3

I am a noob in java ee

But to learn it I should connect to mysql!

I have googled about a day:

Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection("mysql:jdbc://127.0.0.1:3036/shedule", "root", "12345");

said:

java.sql.SQLException: No suitable driver found for mysql:jdbc://127.0.0.1:3036/shedule

0) mysql -h 127.0.0.1 -P 3306 -u root -p works

2) netstat said that mysqld listened to 0.0.0.0:3306

3) lastest netbeans 6.9.1 + glassfish 3.0.1

4) I have ONLY mysql-connector-java-5.1.6-bin.jar no other jars! searched at all hard drives before and after deploy!

it seat at: D:\Program Files\NetBeans 6.9\ide\modules\ext and D:\NetBeansProjects\MyProject\build\web\WEB-INF\lib

5) I have selected "add Library" and mysql-connector-java-5.1.6-bin.jar

6) people said that netbeans deploy this jar to D:\Program Files\glassfish-3.0.1\glassfish\domains\domain1\lib But after deploy there are no mysql-connector-java-5.1.6-bin.jar

7) I have unpacked source of this connector (5.1.14) to my src/java folder

added libraries ant-contrib.jar c3p0-0.9.1-pre6.jar and jboss-common-jdbc-wrapper.jar

My project builds and deploys normaly but work with this exception!

Finaly: alt text

puchu
  • 3,294
  • 6
  • 38
  • 62

3 Answers3

3

That error means your URL is incorrect. That's what that exception usually means.

"mysql:jdbc://127.0.0.1:3036/shedule"  

should be this:

"jdbc:mysql://127.0.0.1:3306/shedule"

The "jdbc" and "mysql" are backwards. And, as noted earlier, the default port is incorrect.

You'll have to reverse all that crazy stuff you tried to fix this. You should have the MySQL connector JAR in one place, either a /lib directory for your app server if it's shared or in WEB-INF/lib of your application. Nowhere else.

duffymo
  • 305,152
  • 44
  • 369
  • 561
1

I see one inconsistency:

Connection connection = DriverManager.getConnection("mysql:jdbc://127.0.0.1:3036/shedule", "root", "12345");

you're specifying 3036 as port.

Later on you say:

netstat said that mysqld listened to 0.0.0.0:3306

From my experience, 3036 != 3306

darioo
  • 46,442
  • 10
  • 75
  • 103
0

all you have to do in netbeans is 1. start a new Java web application project 2. download the latest JDBC driver from here; rite now its running at 5.1.14 3. extract that file, and physically copy and paste the .jar folder into the "Libraries" folder of your netbeans web application project. 4. thats it.

Dhruv Gairola
  • 9,102
  • 5
  • 39
  • 43
  • hi puchu, sorry my bad. shdve read the details better.. you seem to have done everything right actually.. only thing i can suggest is you're using "mysql-connector-java-5.1.6-bin.jar". try downloading the latest version and try? – Dhruv Gairola Dec 26 '10 at 10:09