problem with JSP-MySQL connection
Hi,I'am a newbie in JSP,& try to write the following program :
<%@ page language="java" import="java.sql.*" %>
<%
Class.forName("com.mysql.jdbc.Driver" ) ;// load ok
//these 2 lines is the problem, I think
Connection myConn=DriverManager.getConnection("jdbc:mysql//localhost/test","root","rahasia" ) ;
myConn.close();
%>
<html>
<head>
<title>membuat tabel dengan JSP</title>
</head>
<body>
Connection OK!..........
</body>
</html>
The Driver can be loaded, but if i add those 2 lines (Connection..... & myConn.........)
messages appear on the browser like this :
exception
javax.servlet.ServletException: No suitable driver
org.apache.jasper.runtime.PageContextImpl.doHandle PageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:758)
org.apache.jsp.database.btabel_jsp._jspService(bta bel_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
root cause
java.sql.SQLException: No suitable driver
java.sql.DriverManager.getConnection(DriverManager .java:532)
java.sql.DriverManager.getConnection(DriverManager .java:171)
org.apache.jsp.database.btabel_jsp._jspService(bta bel_jsp.java:47)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
What's wrong ? MySQL is up,and connection with PHP is OK!
I use Tomcat 5.0.27 + MySQL 4.0.18 in Linux Mdk + java version 1.4.2 + mysql-connector-java-3.0.14.
|