代码如下:
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="java.io.*"%>
<%
String url="jdbc:mysql://localhos:3306/mydatabase";
String userName="root";
String password="471414388";
Connection conn= null;
String stu_id=request.getParameter("num");
Statement stmt=null;
String sql=null;
try{
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e){out.println("加载驱动器类出现异常");}
try{
conn=DriverManager.getConnection(url,userName,password);
stmt=conn.createStatement();
sql="select * from student";
ResultSet rs=stmt.executeQuery(sql);
%>
<%
while(rs.next()){
int id=rs.getInt(1);
String name=rs.getString(2);
String address=rs.getString(3);
String birthdate=rs.getString(4);
%>
<tr>
<td><%=id%></td>
<td><%=name%></td>
<td><%=address%></td>
<td><%=birthdate%></td>
</tr>
<%
}
rs.close();
stmt.close();
}catch(SQLException e){out.println("连接数据库过程中出现SQL异常");}
finally{
try{
if(conn != null)
conn.close();}catch(SQLException e){
out.println("关闭数据库连接时出现SQL异常");}
}%>
已经把connector放在lib下了,但是还是一直SQL异常的错,到底应该怎么办嘤嘤嘤QAQ
很急!求救!QAQ