File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes URL for MySQL database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "URL for MySQL database" Watch "URL for MySQL database" New topic
Author

URL for MySQL database

Richard Scothern
Ranch Hand

Joined: May 25, 2001
Posts: 83
Hi,
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?
Thanks,
Richard
Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1757
    
    3
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".
...
...
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
...
...
Connection con = DriverManager.getConnection( "jdbc:mysql://localhost/soup" );
[ July 04, 2002: Message edited by: Michael Matola ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URL for MySQL database