This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes how to connect mysql database? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to connect mysql database?" Watch "how to connect mysql database?" New topic
Author

how to connect mysql database?

Markandey Sahu
Greenhorn

Joined: Jun 29, 2006
Posts: 13
Can any one give me code for connecting mysql database?
Wich driver we can use for connecting database.
pls give me complete code..
Class.forName("???");
Connection con =DriverManage.getConnection("???","??","??");
what i have to write in place of ???
Syskata Mitev
Ranch Hand

Joined: Aug 23, 2006
Posts: 51
Class.forName("com.mysql.jdbc.Driver").newInstance();

database url : jdbc:mysql://localhost:3306/database_name

and check http://www.mysql.com/products/connector/j/ for connector downloading.

4ng().live.healtly;
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

Add your jconnector jar file to your classpath or copy it in your lib directory.

driverClass: com.mysql.jdbc.Driver

URL : jdbc:mysql://<serverhost:port>/<db name>

For more information, here is the URL


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to connect mysql database?
 
Similar Threads
MySQL help
mysql driver????
data source Problem in Struts
how to mysql database?
How Upload Image to DataBase