File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes URL for MySQL database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "URL for MySQL database" Watch "URL for MySQL database" New topic

URL for MySQL database

Richard Scothern
Ranch Hand

Joined: May 25, 2001
Posts: 83
I'm currently in the process of connecting a java application to a mysql database. I'm using the mm.mysql JDBC driver on Windows 2000 with J2se 1.4.
What I need to know is how to decide what url to use to get a connection.
The database is running on the same machine, so I assume it's called localhost, but how do I find the port number? And do I need to include the name of the database I want to use?
Michael Matola
Ranch Hand

Joined: Mar 25, 2001
Posts: 1793
The JavaRanch Cattle Drive JDBC assignments use MySQL and there's good info on that page about getting things set up and running.
On that page you'll find a class called Test that gets an instance of the MySQL driver and gets a connection to a local database called "soup".
Connection con = DriverManager.getConnection( "jdbc:mysql://localhost/soup" );
[ July 04, 2002: Message edited by: Michael Matola ]
I agree. Here's the link:
subject: URL for MySQL database
It's not a secret anymore!