This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection problem with MYSQL

 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I'm trying to run an example from at tutorial and the connection doesn't seem to be made properly. Is ther anything wrong with this code?

- I have the JDBC driver installed and in the class path.
- The account and password strings contain the correct info
- the port number is correct

Ideas??
Thanks in advance.
Terry
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I sorted it out by myself.
The problem was that I didn't need to pass in the user and login as I am running it on W98.
So I changed the get.Connection() to include "" for account and password.

Bye,
Terry
 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks!

I am trying to do what Terrance did, namely connect a Java program to MySQL. Reading this post, I realise I have not installed the Connector/J driver and it's not in my class path. How do you do this? I have downloaded the Connector/J zip file (I am using windows XP) from MySQL into a separte directory on my drive and I have extracted a load of stuff but I have no idea where the driver is or how to configure it. Has anyone done this before, I have been horsing about clueless for days on this and if I don't get it sorted soon, I shall become seriously depressed!
 
Jason Moors
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you search for mysql-connector-java*.zip you should be able to find the driver ZIP file.

Contained within the ZIP file there should be a JAR file named something like mysql-connector-java-3.1.12-bin.jar (depending on your version).

You need to extract the file to certain location and then add the JAR file to your CLASSPATH environment variable.

i.e if you extract to c:\msqldriver

you need to add to CLASSPATH

c:\mysqldriver\mysql-connector-java-3.1.12-bin.jar

Jason
 
benny rusli
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or you can put the mysql connector jar file into the directory where you install your jdk or jre. Specifically put into the directory : c:/Java/jdk1.5.0/jre/lib/ext or if you only install jre c:/Java/jre1.5.0/lib/ext. I hope this help you.
 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, guys! Everything is up and running. What a brilliant web site this is!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic