Struts2 example, not inserting records in mysql database because connection object is getting null
- by Jugal
This Code is working fine with simple application so the drivers are fine.
so why the connection object is not able to initialise with drivers. 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import com.opensymphony.xwork2.ActionSupport;
public class Insert extends ActionSupport {
public String execute() throws Exception, SQLException {
	String sql = "";
	String url = "jdbc:mysql://localhost:3306/test";
	//String dbName = "test";
	String driverName = "org.gjt.mm.mysql.Driver";
	String userName = "root";
	String password = "root";
	Connection con=null;
	Statement stmt=null;
	try {
		Class.forName(driverName).newInstance();
		con = DriverManager.getConnection(url, userName, password);
		stmt = con.createStatement();
	} catch (Exception e) {
		System.out.println(e.getMessage());
	}
}