Re: how to connect Java Application to MySQL
Posted by: Sellappan Subbiah
Date: December 27, 2005 04:26AM

Hi
I have tried the following statements to connect java with MySQL


try
{



String userName = "root";
String password = "root";

// by default MySQL runs on localhost
String url = "jdbc:mysql://localhost//"+database;

Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch(Exception e)
{
e.printStackTrace();
}


it is working for me without any error.

Thanks
Sella

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.