本人用Servlet写对
数据库进行取值,那个
数据库是时时刷新的,现在我通过
手机查看,要时时取值,通过Timer实现,现在出现的问题的是,第一个取值成功,以后就不能取值报java.io.EOFException错误,请问该怎么解决啊
public class servlet1 extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html; charset=GBK"); // 设置响应属性
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException ex)
{
}
try
{
String URL = "jdbc

dbc:dbf";
Connection con = DriverManager.getConnection(URL);
Statement stmt = con.createStatement();
InputStream is = request.getInputStream();
DataInputStream dis = new DataInputStream(is);
String readStr1 = dis.readUTF(); // 读入第一个参数
String SQL = "SELECT * FROM XFQ WHERE HQ=" + "'" + readStr1+ "'";
ResultSet rs = stmt.executeQuery(SQL);
DataOutputStream dos = new DataOutputStrem(response.getOutputStream());
while (rs.next())
{
dos.writeUTF(rs.getString("HQ1")+"\n");
dos.writeUTF(rs.getString("HQ2")+"\n");
break;
}
rs.close();
dis.close();
dos.close();
stmt.close();
con.close();
} catch (SQLException ex)
{
}
}