I am trying to set up a java server page and mysql. I have installed jdk and all of the neccessary tools and drivers. I am using Tomcat for the servlet container. I have also set up an account with a password on mysql. I think that the only issue that stands in the way is setting the classpath for the database driver. What jar file is it supposed to point to? This is what I have downloaded for a driver.
mysql-connector-java-2.0.14
This is the classpath I have set
CLASSPATH=C:/mm.mysql-connector-2.0.6.1.jar;C:\tomcat\common\lib\servlet
.jar;C:\tomcat\common\lib\mm.mysql-connector-2.0.6.1.jar;C:\tomcat\common\lib\my
sql-connector-java-2.0.14-bin.jar;.
I am not sure if I am still missing anything. I still get this error. I can compile .jsp files with no problem but when I try to access a database it just wont work. What is the correct jar file it needs to point to? This one
mm.mysql-connector-2.0.6.1.jar or this one
mysql-connector-java-2.0.14-bin.jar;. I am really getting confused here.
This is the error I recieve.
org.apache.jasper.JasperException: org.gjt.mm.mysql.Driver
Could someone help? I would like the full classpath in detail if possible.
Below is the code I am trying to use.
<%@ page language="java" import="java.sql.*" contentType="text/html;charset=KSC5601" %>
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url="jdbc:mysql://localhost/wrox";
Connection Conn=DriverManager.getConnection(url,"rob","ropo2121");
Statement stmt = Conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from books");
if (!rs.next()) {
out.println("empty~~~");
} else {
out.println(rs.getString(1));
}
stmt.close();
Conn.close();
%>