关于jsp连接mysql的问题
新学jsp连接mysql,按照教程把mysql-connector-java-5.0.4-bin.jar拷贝到了tomcat的lib目录下,也拷贝到了web-inf/lib下面,可是每次执行都报“
java.sql.SQLException: No suitable driver found for jdbc.mysql..."错误。具体代码如下:
<%@ page language="java" import="java.sql.*,javax.sql.*" pageEncoding="UTF-8"%>
<%@ page import="com.mysql.jdbc.Driver" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<%
try{
//载入Mysql驱动
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url="";
Connection conn=DriverManager.getConnection("jdbc.mysql://localhost:3306","root","");
Statement state=conn.createStatement();
int result=state.executeUpdate("insert into User(Uname,Upass) values('"+ request.getParameter("uname"
) + "','" + request.getParameter("upass") + "')");
if(result == 1){
out.println("用户注册成功!");
}else{
out.println("用户注册失败!");
}
}catch (
SQLException e){
out.println(e);
}
%>
</body>
</html>
求问如何解决此问题。
------解决方案--------------------