To connect to the database, you need to use a JDBC url with the following format
jdbc:mysql://[hostname][:port]/[dbname][?param1=value1][¶m2=value2].....
This is described in the Driver documentation. Accordingly, the piece of code you must use is:
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
} catch (ClassNotFoundException cnfe)
{
System.err.println("Error loading driver:"+cnfe);
}
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/Authority?user=root&password=fox123");
}
here hostName=localhost
dbname=Authority
user=root
password=fox123
Java Tips by :
Karmegam
Quick Links:
Do you have
a Java Question?
Best Regards,
Java Programming Hints and Tips
All the site contents are Copyright © www.sap-img.com
and the content authors. All rights reserved.
All product names are trademarks of their respective
companies.
The site www.sap-img.com is not affiliated with or endorsed
by any company listed at this site.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
The content on this site may not be reproduced
or redistributed without the express written permission of
www.sap-img.com or the content authors.