Sunday, September 11, 2011

Connecting Mysql in tomcat server in linux


You can connect to mysql in tomcat
- Setup mysql
Download Mysql click here
-download mysql connector(driver) and add file .jar to your project
Click here to download jconnector

-run mysql create datasource

Example for connecting the mysql in tomcat jsp
public static Connection getConnection(){
try{
Connection conn DriverManager.getConnection(“jdbc:mysql://127.0.0.1/lamtung?user root&password password”);
return conn;
}
catch(SQLException se)
{
se.printStackTrace();
return null;
}
}