The moose likes JDBC and the fly likes Connecting to mysql Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JDBC
Reply Bookmark "Connecting to mysql" Watch "Connecting to mysql" New topic
Author

Connecting to mysql

Chris-Huisman
Greenhorn

Joined: Jan 25, 2002
Posts: 23
Hello,
I am attempting to connect to a mysql database, but I don't quite know how to specify were the table is. My host is localhost, and I specify it like this:
jdbc:mysql://localhost/table1
but I end up with an SQLException.
How do you specify the correct host??
thanks,
c.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 563
Originally posted by Chris-Huisman:
Hello,
jdbc:mysql://localhost/table1
but I end up with an SQLException.

That's not the table you specify there, it's the database name. In mysql to start with on installation, you have only 2: test & mysql. You can make your own one for your app in sql with
create database chris1;
use chris1;
so your url would be:
jdbc:mysql://localhost/chris1
hth,
adam


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Chris-Huisman
Greenhorn

Joined: Jan 25, 2002
Posts: 23
Thanks for your help, but I figured out what my problem was. I neglected to add the port after //localhost.
Thanks,
c.
 
 
subject: Connecting to mysql
 
Threads others viewed
java.net.ConnectException: Connection refused: connect
Access denied for user 'root@localhost' (using password:NO) error in MySQL
JDBC Connection Problem
Please guide me
Removing Eclipse Ganymede
developer file tools