我的JSP代码
<%@ page contentType="text/html; charset=gb2312" language="java"
import="java.sql.*" errorPage=""%>
<jsp:useBean id="conndbbean" scope="page" class="vote.vote_conn" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>网上调查</title>
<link rel="stylesheet" type="text/css" href="style.css">
<style type="text/css">
<!--
.STYLE1 {color: #0000ff}
.STYLE2 {font-size: 14px}
-->
</style>
</head>
<%ResultSet rs = conndbbean.executeQuery("select * from vote");
%>
<body>
<div align="center" class="STYLE1">请您投票</div>
<form action="vote.jsp" method="post" enctype="multipart/form-data"
name="form1" target="_parent" id="form1">
<%try{while (rs.next()) {
%>
<tr>
<td><input type="radio" name="type" value=<%=rs.getString("id")%>><%=rs.getString("note")%></td>
</tr>
<%}
rs.close();}catch(NullPointerException e){out.println("NullPointerException ");}%>
<tr align="center">
<td><input type="submit" name="Submit" value="投票"></td>
</tr>
</form>
<p>查看投票</p>
</body>
</html>
bean的JAVA代码
package vote;
import java.sql.*;
public class vote_conn{
String sdbdriver="sun.jdbc.odbc.JdbcOdbcDriver";
String sconnstr="jdbc:odbc:vote";
Connection connect=null;
ResultSet rs=null;
public vote_conn(){
try{
Class.forName(sdbdriver);
}catch(java.lang.ClassNotFoundException e){System.err.println(e.getMessage());
}
}
public ResultSet executeQuery(String sql){
try{
connect=DriverManager.getConnection(sconnstr,"","");
Statement stmt=connect.createStatement();
rs=stmt.executeQuery(sql);
}catch(SQLException ex){System.err.println(ex.getMessage());
}
return rs;
}
public int executeUpdate(String sql){
int result=0;
try{
connect=DriverManager.getConnection(sconnstr);
Statement stmt=connect.createStatement();
result=stmt.executeUpdate(sql);
}catch(SQLException ex){System.err.println(ex.getMessage());
}
return result;
} }
运行出现:
NullPointerException 投票
查看投票
请问怎么解决啊?
谢谢哦
[此贴子已经被作者于2006-8-9 22:20:17编辑过]