• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting to mysql

 
Chris-Huisman
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Chris-Huisman
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help, but I figured out what my problem was. I neglected to add the port after //localhost.
Thanks,
c.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic