java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Posted by:
yilinglim
Date: July 29, 2004 12:36AM
hi there,
i'm failed to connect the MySQL driver, anyone can help me?
i don't know where comes wrong !
following are the script that i type in .jsp ----------->
<%@page contentType="text/html"%>
<%@page import="java.sql.*"%>
<%@page import="javax.servlet.http.*"%>
<%@page import="java.lang.*"%>
<%@page buffer='none'%>
<html>
<head><title>Early Warning System</title></head>
<body>
<%
Connection conn = null;
Statement stm = null;
ResultSet rst=null;
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://buah:3306/epal","mangga","123456");
stm = conn.createStatement();
out.println("success<br>");
} catch (Exception exc) {
exc.printStackTrace();
out.println(exc.toString());
out.println("failed<br>");
}
String sql = "select distinct Year from sunny";
rst = stm.executeQuery(sql);
while(rst.next()) {
out.print(rst.getString("Year"));
}
%>
Hello..
<%
rst.close();
stm.close();
conn.close();
%>
</body>
</html>
----------------------------------------------------------------------------------------------------------
anything wrong about my script ?? for the Class.forName, i tried
Class.forName("com.mysql.jdbc.Driver").newInstance();
too.... but also cant work..
everytime i run the code, it will display
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver and failed!!
Any help will be appreciated.