The method getRecordingBysqdh(String) is undefined for the type MzsqdDao
时间: 2024-05-30 08:13:37 浏览: 10
对于这个问题,可能有几种可能的情况。首先,可能是MzsqdDao类中确实没有定义名为getRecordingBysqdh的方法。其次,有可能是getRecordingBysqdh方法的参数类型不正确,或者方法被声明为了私有的而无法访问。最后,也有可能是MzsqdDao类没有被正确地导入或引入。您可以仔细检查一下上述几种情况,或者提供更多的细节来帮助我更好地回答您的问题。
相关问题
The method sub(String) is undefined for the type String
As an AI language model, I can say that the error message "The method sub(String) is undefined for the type String" typically occurs when you try to call the sub() method on a String object in Java, but the method is not defined for the String class. The sub() method is used to extract a substring from a String object based on the specified index range.
To resolve this error, you need to ensure that you are calling the sub() method on a valid object that has this method defined. You can also check the Java documentation to verify the syntax and usage of the sub() method.
the method preparement(String) is undefined for the type SQLConn
抱歉,我的回答中有误。应该将SQLConn类中的openDB方法改为返回Connection对象,然后在JSP页面中使用该Connection对象创建PreparedStatement对象。
具体修改如下:
SQLConn.java:
public class SQLConn {
// 省略其他代码
// 修改openDB方法
public static Connection openDB() throws ClassNotFoundException, SQLException {
// 加载JDBC驱动
Class.forName("com.mysql.jdbc.Driver");
// 创建数据库连接
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "123456");
// 返回连接对象
return conn;
}
// 省略其他代码
}
login.jsp:
<%@ page language="java" import="java.util.*, java.sql.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>登陆跳转servlet</title>
</head>
<body>
<%
String usernum = request.getParameter("usernum");
String userpwd = request.getParameter("userpwd");
Connection conn = SQLConn.openDB();
// 使用PreparedStatment进行预编译
PreparedStatement pstmt = conn.prepareStatement("select UserId, Code from User_ZC where usernum=? and userpwd=?");
pstmt.setString(1, usernum);
pstmt.setString(2, userpwd);
ResultSet rs = pstmt.executeQuery();
boolean v = rs.next();
rs.close();
pstmt.close();
conn.close();
if(v){
request.getRequestDispatcher("ZCS.jsp").forward(request, response);
}else{
request.getRequestDispatcher("ZCB.jsp").forward(request, response);
}
%>
</body>
</html>
在JSP页面中,我们使用SQLConn类的openDB方法获取数据库连接,然后使用该连接对象创建PreparedStatement对象,设置参数并执行查询。在使用完PreparedStatement和ResultSet之后,及时关闭资源。
再次抱歉给您带来的困扰。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)