发新话题
打印

急急急,请大家帮帮忙

急急急,请大家帮帮忙

本人用Servlet写对数据库进行取值,那个数据库是时时刷新的,现在我通过手机查看,要时时取值,通过Timer实现,现在出现的问题的是,第一个取值成功,以后就不能取值报java.io.EOFException错误,请问该怎么解决啊

TOP

把你连servlet的那段代码贴出来看看阿,是不是connection没有关?
在线制作自己的手机软件,就在胖胖网
================
= 人は遊び存在である。 =
= To Play is Human.       =
================

TOP

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
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 = "jdbcdbc: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 HHQ 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");
                                dos.writeUTF(rs.getDouble("HQ3")+"\n");
                                dos.writeUTF(rs.getDouble("HQ4")+"\n");
                                dos.writeUTF(rs.getDouble("HQ5")+"\n");
                                break;
                        }
                        rs.close();
                        dis.close();
                        dos.close();
                        stmt.close();
                        con.close();
                } catch (SQLException ex)
                {

                }

        }

        public void doPost(HttpServletRequest request, HttpServletResponse response)
                        throws ServletException, IOException
        {
                doGet(request, response);
        }

        public void destroy()
        {
        }
        // 清除资源
}

[ 本帖最后由 supergo 于 2008-5-12 01:52 PM 编辑 ]

TOP

发新话题