JavaServer Pages (JSP) and JSTL - JSP/MySql and JDBC/MySql
I have downloaded and copied the this Connector/j to lib directory of my java installation dir.
and this Jsp page is working with that.
<%@ page language="java" import="java.sql.*" %>
<%
String driver ="org.gjt.mm.mysql.Driver";
Class.forName(driver).newInstance();
Connection con=null;
ResultSet rst=null;
Statement stmt=null;
try
{
String url="jdbc:mysql://localhost/books?user=root&password=dba";
con=DriverManager.getConnection(url);
stmt=con.createStatement();
out.println("Connected");
}
catch(Exception e)
{
out.println(e.getMessage());
}
%>
But I couldn't get connect with this java file.
import java.sql.*;
publicclass LoadDriver
{
publicstaticvoid main(String[] args)
{
try
{
Connection con=null;
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://localhost/books?user=root&password=dba";
con=DriverManager.getConnection(url);
System.out.println("Connected...");
}
catch (Exception ex)
{
System.out.println(ex.getMessage());
}
}
}
The exception is the name of the driver. how to solve this problem.

