有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java为什么在连续运行servlet时执行“DriverManager.getConnection”(“credentials”)时显示“找不到侦听器”错误?

当我连续多次运行下面的servlet时,在插入几行数据后,它会卡在“drivermanager.getconnection”部分,我无法继续这个过程。我必须重新启动整个web应用程序,才能从它卡住的地方继续这个过程。有谁能帮我知道这里有什么问题吗?这里还需要做些什么来避免这个问题?我使用的是属性文件、可调用语句、预处理语句,但都不能解决这个问题

/*all the imports*/

public class PtRegSer extends HttpServlet {



protected void doGet(HttpServletRequest request, HttpServletResponse response)     throws ServletException, IOException {

    /*values to put in the table*/
    try
    {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }
    catch(ClassNotFoundException e)
    {
        System.out.println(e);
    }
    Connection conn=null;
    Statement stmn=null;
    try
    {
        System.out.println("1");
        conn=DriverManager.getConnection("jdbc:odbc:xyz","system","123456");
        System.out.println("2");
        stmn=conn.createStatement();
        System.out.println("3");            
        stmn.execute("insert into ptregt values('"+pregno+"','"+pname+"','"+pgender+"','"+page+"','"+paddr+"','"+ptrtmnt+"','"+pdoc+"','"+prfee+"','"+preguser+"',to_date('"+pdate+"','yyyy-MM-dd'))");     
        b=true;
    }
    catch(SQLException e)
    {
        e.printStackTrace();
    }


}

}


共 (0) 个答案