Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我无法在eclips中将mysql与jsp连接_Mysql_Jsp - Fatal编程技术网

我无法在eclips中将mysql与jsp连接

我无法在eclips中将mysql与jsp连接,mysql,jsp,Mysql,Jsp,我正在发布我的代码、错误和数据库名称记录 我也做了jdbc连接,仍然无法传递数据。我的代码或安装中是否有错误 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="java.sql.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Tran

我正在发布我的代码、错误和数据库名称记录

我也做了jdbc连接,仍然无法传递数据。我的代码或安装中是否有错误

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

<%@ page import="java.sql.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Home</title>

</head>
<body>
<%
Connection con= null;
PreparedStatement ps = null;
ResultSet rs = null;

String url = "jdbc:mysql://localhost:3306/record";
String user = "root";
String password = "password";


try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("url", user, password);

String sql = "select usertype from userdetail";

ps = con.prepareStatement(sql);
rs = ps.executeQuery(); 


%>
<form method="post" action="login.jsp">
<center><h2 style="color:green">JSP Login Example</h2></center>
<table border="1" align="center">
<tr>
<td>Enter Your Name :</td>
<td><input type="text" name="name"/></td>
</tr>
<tr>
<td>Enter Your Password :</td>
<td><input type="password" name="password"/></td>
</tr>
<tr>
<td>Select UserType</td>
<td><select name="usertype">
<option value="select">select</option>
<%
while(rs.next())
{
String usertype = rs.getString("usertype");
%>
<option value=<%=usertype%>><%=usertype%></option>
<% 
}
}
catch(SQLException sqe)
{
out.println("home"+sqe);
}
%>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="submit"/></td>
</table>
</form>
</body>
</html>
注意,Apache Tomcat/6.0.43日志中提供了根本原因的完整堆栈跟踪。

尝试插入以下内容:

DriverManager.registerDriver(new com.mysql.jdbc.Driver());

在获得JDBC连接之前。

很抱歉,我提到了数据库表作为测试,但它是“记录”的。您使用的是mysql驱动程序连接器吗?可能是
java.lang.ClassNotFoundException
导致问题吗?@Paulo我使用的是mysql驱动程序
DriverManager.registerDriver(new com.mysql.jdbc.Driver());