0

I've been working on installing Connector/J on my computer, but I can't make it work. There are some problems I encounter along the way. Here is what I did:

(based on what I read in the internet)

First I downloaded mysql-connector-java-5.0.8. After extracting it, I guess I am supposed to put mysql-connector-java-5.0.8-bin.jar where my classpath is. Here I have a problem, after installing java jdk v8, I don't get any variable called classpath in my environment variable. So how am I supposed to put it somewhere without knowing where?

I read in the net that I should put it in C:\Program Files\Java\jdk1.8.0_45\jre\lib\ext

And then I have to set the classpath variable accordingly. I created a new variable and set it with variable name : classpath and variable value : C:\Program Files\Java\jdk1.8.0_45\jre\lib\ext

After running my program in Netbeans (the program is supposed to connect to a database) I get this error:

No suitable driver found for jdbc:mysql://127.0.0.1:3306

Which is for the line that I am trying to get a connection :

connection = DriverManager.getConnection(DATABASE_URL, "reza", "reza" );

I really have no idea what is happening here. I am lost, I searched over and over again but nothing seemed to work.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
reza71
  • 37
  • 1
  • 3
  • Try again.. On you program (On netbeans) click on Library directory -> add Jar/folder -> Browse to your mysql driver. Then clean and build again ! Hope to help ! – CodeMonster Aug 08 '15 at 16:50
  • Never ever install something into `lib\ext`; this is not what it was intended for, and it will be removed in future Java versions. – Mark Rotteveel Aug 08 '15 at 20:24
  • Also note that mysql connector/J 5.0.8 is **very old**. Your attempt to set the classpath fails because most methods of executing java applications **don't use it**. – Mark Rotteveel Aug 08 '15 at 20:31
  • hi CodeMonster , thanks for the help , what do you mean by clean and build again ? you mean now that i have set my classpath then i should copy mysql-connector-java-5.0.8-bin.jar there? am i right ? – reza71 Aug 09 '15 at 04:45
  • Hi mark , thanks for the reply , you said that mysql-connector-java-5.0.8 is very old , but this is the latest version available i believe , so what should i do? – reza71 Aug 09 '15 at 04:47
  • See http://dev.mysql.com/downloads/connector/j/ latest version: 5.1.36 – Mark Rotteveel Aug 12 '15 at 11:05

0 Answers0