求大佬解答一下是什么问题啊
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*" %>
<%
int id = Integer.valueOf(request.getParameter("number"));
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/maiba","root","3268620");
Statement stmt = conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from worker where id="+id);
if(rs.next()){
out.print(" id: " + id);
out.print("; name: " + rs.getString(2));
out.print("; sex:" + rs.getString(3));
out.print("<BR>");
}
}catch(SQLException e){
e.printStackTrace();
}
%>
本文提供了一个使用Java从MySQL数据库中查询数据的例子。通过设置页面语言为Java,并导入必要的SQL包,该示例展示了如何连接到本地数据库并执行SQL查询以获取指定ID的员工信息。
1640





