| |
GeekInterview.com > Interview Questions > J2EE > Struts
| Print | |
Question: How to connect data source for mysql in tomcat server
|
| June 06, 2008 03:08:17 |
#1 |
| nguoitinhcuasong |
Member Since: August 2007 Total Comments: 1 |
RE: How to connect data source for mysql in tomcat server |
You can nonnect to mysql datasource without tomcat server by folowing way:
- Setup mysql -download mysql connector(driver) and add file .jar to your project -run mysql, create datasource - Write code to connect to that datasource:
public static Connection getConnection(){
try{ Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1/lamtung?user=root&password=vertrigo"); return conn; } catch(SQLException se) { se.printStackTrace(); return null; } } |
| |
Back To Question | |