| |
GeekInterview.com > Interview Questions > J2EE > Struts
| Print | |
Question: How to connect data source for mysql in tomcat server
|
| July 07, 2009 09:45:09 |
#3 |
| masarrat |
Member Since: July 2006 Total Comments: 9 |
RE: How to connect data source for mysql in tomcat server |
First download mysql.jar and mysql connector then load the driver
Class.forName("com.mysql.jdbc.Driver");
then create a database in mysql lets assuse "test" is the database name. for using mysql we must provide user name and password while obtaining connection. here we assume "root" is username and password as well. so the code will be
Connection con =DriverManager.getConnection("mysql://localhost:3306/test","root","root"); |
| |
Back To Question | |