How to Connect with mysql database?
<p>I am trying to connect MySL database but some error in this code so please help me.</p>

<pre><code>import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class MyClass {
    static public final String driver = "com.mysql.jdbc.Driver";
    static public final String connection ="jdbc:mysql://localhost:3306/ashu";
    static public final String user = "root";
    static public final String pass= "admin";
    ResultSet rs;
    Connection con;
    Statement smt;



    public Connection openConnection(){
        try{
            Class.forName(driver);
            con=DriverManager.getConnection(connection,user,pass);
            smt=con.createStatement(rs.TYPE_SCROLL_SENSITIVE,rs.CONCUR_UPDATABLE);
        }catch(Exception ex){
            System.out.println("Connection Failed: "+ex);
        }
        return con;
    }
    public void closeConnection(){
        try{
            con.close();
        }catch(Exception ex){
            System.out.println("Closing Connection Failed*****");
        }
    }

    public String getData(String id){
        String result="";
        openConnection();
        try{
            rs=smt.executeQuery("select name from mytable where no="+id);
            while(rs.next()){
                result=rs.getString(1);
            }
        }catch(Exception ex){
            System.out.println("getData() Failed*****");
        }
        System.out.println("Result*****"+result);
        closeConnection();
        return result;
    }
}
</code></pre>
