package Disease1;
import java.sql.*;
import java.lang.String;
//数据库连接
public class benchmark {
Statement stmt=null ;
ResultSet rs=null ;
public Connection getConn() throws Exception {
Connection conn = null;
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://MICROSOF-1F1693:1433;DatabaseName=BecheDisease;user=sa;password=******");
}catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
public void Exec(String sql){//执行sql语句
try{
getConn();
stmt.executeUpdate(sql);
}catch(Exception e){
System.out.print("exec=="+e);
}
}
public ResultSet getRs(String sql)throws SQLException {//获取查询语句集对象
try{ getConn();
rs=stmt.executeQuery(sql);
return rs; }
catch(Exception e){
System.out.print(e);
return null; }}
}
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<%@ page import="java.sql.*"%>
<jsp:useBean id="getConn" scope="page" class="Disease1.benchmark" />
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>海参疾病诊断查询</title>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="content-language" content="en-gb" />
<link rel="stylesheet" type="text/css" href="fund.css">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<script language="JavaScript">
</script>
<body><form>
<div class="topic">
<div class="topicBox">
<table align=center width=100% border="0"
style="border-bottom: 1px solid #aaaaaa; margin: 0px 0px 8px 8px;">
<tr><td><h3>请选择海参病变症状</h3></td></tr>/table>
<table width=100% align=center border=0>
<%String sql = "select Symptom from Symptom_table ";
ResultSet rs = getConn.getRs(sql);
int intMax=0;
while(rs.next()){
intMax++;
}rs.close();
String[] Symptom=new String[intMax];
rs = getConn.getRs(sql);
if(intMax>0){
int i=0;
while (rs.next()) {
String Symp=rs.getString(2);
Symptom[i]=Symp;
i++;
rs.close();
}else{rs.close();}
%>
<tr><td valign=top align=left>
<% for (int i = 0; i < Symptom.length; i++) { %>
<input name="Symptom" type="checkbox" />
<option value=<%= i %>><%=Symptom[i]%></option>
<%
}
%>
</td>
</tr>
</table>
</div></div>
</form><br></body>
</html>
错误信息
description The server encountered an internal error () that prevented it from fulfilling this request.
exception org.apache.jasper.JasperException: An exception occurred processing JSP page /search.jsp at line 53
50:String sql = "select Symptom from Symptom_table ";
51:ResultSet rs = getConn.getRs(sql);
52:int intMax=0;
53:while(rs.next()){
54:intMax++;
55:}rs.close();
56:String[] Symptom=new String[intMax];