HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: javax.servlet.ServletException: com.mysql.jdbc.CommunicationsException: The driver was unable to create a connection due to an inability to establish the client portion of a socket.This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable. For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required.For Windows-based platforms, see Microsoft Knowledge Base Article 196271 (Q196271).
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:532)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:408)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause javax.servlet.ServletException: com.mysql.jdbc.CommunicationsException: The driver was unable to create a connection due to an inability to establish the client portion of a socket.This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable. For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required.For Windows-based platforms, see Microsoft Knowledge Base Article 196271 (Q196271).
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:855)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:784)
org.apache.jsp.manager.inser_jsp._jspService(inser_jsp.java:95)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause com.mysql.jdbc.CommunicationsException: The driver was unable to create a connection due to an inability to establish the client portion of a socket.This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable. For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required.For Windows-based platforms, see Microsoft Knowledge Base Article 196271 (Q196271).
com.mysql.jdbc.Connection.createNewIO(Connection.java:2814)
com.mysql.jdbc.Connection.<init>(Connection.java:1553)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
cn.com.util.DataBase.openConnection(DataBase.java:16)
cn.com.util.DataBase.dataUpdates(DataBase.java:106)
cn.com.bean.A_Operation.new_operation(A_Operation.java:22)
org.apache.jsp.manager.inser_jsp._jspService(inser_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
--------------------------------------------------------------------------------Apache Tomcat/6.0.10

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主截止到2008-06-21 08:00:02的汇总数据:
    注册日期:2008-3-2
    上次登录:2008-6-21
    发帖数:2                  发帖分:40                 
    结贴数:0                  结贴分:0                  
    结贴率:0.00 %        结分率:0.00 %        
    如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
      

  2.   


    异常如下com.mysql.jdbc.CommunicationsException: The driver was unable to create a connection due to an inability to establish the client portion of a socket. This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable. For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required. For Windows-based platforms, see Microsoft Knowledge Base Article 196271 
      

  3.   


    发表于:2008-06-21 08:51:517楼 得分:0 
    引用 4 楼 myooo 的回复:我这个是在插入2000条数据,连续按几下刷新出错的,如何解决 
     
    也就是说不连续刷,程序是可以连接到数据库,且可以正常工作的对么?  ####################################只能插入三次,第四次出错,也就是说只能插入6000杀数据,然后等一会才能重新插入
      

  4.   

    org.apache.jasper.JasperException:  JSP页面发生异常了The driver was unable to create a connection   你看你的驱动包有没有问题.
      

  5.   

    This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable可配置的。
      

  6.   

    see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required已经说的很清楚了
      

  7.   

    在Servlet中数据库没有连接好,客户端的Socket接口没有发生效用,数据链接失败,通常导致这种错误的是因为操作系统的一系列Socket接口被限制使用了,这个限制一般是由配置和结构问题导致的,基于unix操作系统,如果看到"ulimit"字样,你可以让系统重新初始化或者重新配置一下就应该可以了
      

  8.   

    本帖最后由 java2000_net 于 2008-06-22 02:36:51 编辑
      

  9.   

    http://topic.csdn.net/u/20080621/09/8374dd1f-28f8-4da1-94f5-66a4623245ee.html
      

  10.   

    没有看出什么错,给你一点建议
    连接放在finally里关闭
    不要返回ResultSet,封装成list如果你连续插入然后把数据查出来的话,应该是你查询时连接没关闭引起的
      

  11.   

    This is usually caused by a limit on the number of sockets   
      

  12.   

    This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable. For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required. 修改设置,增大socket的连接数。楼主试试 Statement.executeBatch() 。做大批量数据插入,比较好。
      

  13.   

    MySQL:    
        String Driver="com.mysql.jdbc.Driver";    //驱动程序
        String URL="jdbc:mysql://localhost:3306/db_name";    //连接的URL,db_name为数据库名    
        String Username="username";    //用户名
        String Password="password";    //密码
        Class.forName(Driver).new Instance();
        Connection con=DriverManager.getConnection(URL,Username,Password);驱动搞错了吧
      

  14.   

    你报错也是这样的:The driver was unable to create a connection 这个驱动不能创建连接,mysql的驱动加载错误
      

  15.   

    也有可能是用完的connection没有释放导致的,每访问一次数据库,要释放一次资源,内存资源是有限的,建议放在finally中执行,不管抛不抛异常都要释放,这是必须要做的
      

  16.   


       是不是将原来的    //插入数据
        public boolean executeInsert(String insert_SQL) throws Exception {
            pstmt = openConnection().prepareStatement(insert_SQL);
            try {
                pstmt.executeUpdate();
                closePreparedStatement();
                closeConnection();
                return true;
            } catch (Exception ex) {
                System.err.println(ex.getMessage());
                closePreparedStatement();
                closeConnection();
                return false;
            }
        }######################################################
       改成下面这样子呀
        //插入数据
        public boolean executeInsert(String insert_SQL) throws Exception {
            pstmt = openConnection().prepareStatement(insert_SQL);
            try {
                pstmt.executeUpdate();
                return true;
            } catch (Exception ex) {            System.err.println(ex.getMessage());
                
                return false;
            }
             finally
            {
                closePreparedStatement();
                closeConnection();       }
        }
      

  17.   


    我用的是这个包mysql-connector-java-5.0.5-bin.jar
      

  18.   


    我用的是这个包 mysql-connector-java-5.0.5-bin.jar mysql版本是  mysql-5.0.27
      

  19.   

    root cause com.mysql.jdbc.CommunicationsException: The driver was unable to create a connection due to an inability to establish the client portion of a socket. This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable. For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required. 
    造成问题的原因是不是JDBC驱动有问题!
      

  20.   

       //插入数据
        public boolean executeInsert(String insert_SQL) throws Exception {
            pstmt = openConnection().prepareStatement(insert_SQL);
            try {
                pstmt.executeUpdate();
                closePreparedStatement();
                closeConnection();
                return true;
            } catch (Exception ex) {
                System.err.println(ex.getMessage());
                closePreparedStatement();
                closeConnection();
                return false;
            }
        }    //更新数据库数据
        public boolean executeUpdate(String update_SQL) throws Exception {
            pstmt = openConnection().prepareStatement(update_SQL);
            try {
                pstmt.executeUpdate();
                closePreparedStatement();
                closeConnection();
                return true;
            } catch (Exception ex) {
                System.err.println("aq.executeQuery: " + ex.getMessage());
                closePreparedStatement();
                closeConnection();
                return false;
            }
        }    //返回布尔值,数据存在为真,否则为假
        public boolean boolData(String bool_SQL) throws Exception {
            pstmt = openConnection().prepareStatement(bool_SQL);
            boolean bool = false;
            ResultSet rs = null;
            try {
                rs = pstmt.executeQuery();
                if(rs.next()) {
                    bool = true;
                } else {
                    bool = false;
                }
            } catch (Exception ex) {
                System.err.println("sql_data.executeQuery:" + ex.getMessage());
                bool = true;
            }
            rs.close();
            closePreparedStatement();
            closeConnection();
            return bool;
        }    //返回记录数
        public int getResultCount(String count_SQL) throws Exception {
            pstmt = openConnection().prepareStatement(count_SQL);
            int icount = 0;
            ResultSet rs = null;
            try {
                rs = pstmt.executeQuery();
                while (rs.next()) {
                    icount = rs.getInt(1);
                }
            } catch(Exception ex) {
                System.err.println("sql_data.executeQuery:" + ex.getMessage());
                icount = 0;
            }
            rs.close();
            closePreparedStatement();
            closeConnection();
            return icount;
        }
    }
    在关闭连接的时候出错了,然后连接没关好。
    一次性插入2000条数据,开关数据库连接2000次,你不觉得这样非常浪费吗?
    这么高频率的开关数据库连接,不报错才怪了。
    强烈建议修改程序,最好是开一次连接,做n次事务。
      

  21.   

    这样不行吧,一次插入2000条,这个出错也正常了。
    关闭方法做一个方法写吧。
    把关闭方法写在finally{
    }里面啊。
      

  22.   


    package cn.com.util;import java.sql.*;public class DataBase {    public Connection conn=null;
        public PreparedStatement pstmt;    public DataBase()throws Exception {    }    //打开并返回一个数据库连接
        public Connection openConnection() throws Exception {
            String url = "jdbc:mysql://localhost:3306/idata?user=root&password=130411";
            url += "&useUnicode=true&characterEncoding=UTF-8";
            Class.forName("org.gjt.mm.mysql.Driver").newInstance();
            conn = DriverManager.getConnection(url);
            return conn;
        }    //关闭数据库连接
        public void closeConnection() throws Exception {
            try {
                if(conn != null) {
                    conn.close();
                }
            } catch (Exception ex) {
                conn.close();
                System.out.print(ex.toString());
            }
        }    //关闭PreparedStatement
        public void closePreparedStatement() throws Exception {
            try {
                if(pstmt != null) {
                    pstmt.close();
                }
            } catch (Exception ex) {
                pstmt.close();
                System.out.print(ex.toString());
            }
        }    //返回ResultSet
        public ResultSet executeQuery(String m_SQL) {
            ResultSet rs = null;
            try {
                pstmt = openConnection().prepareStatement(m_SQL);
                rs = pstmt.executeQuery();
            } catch (Exception ex) {
                System.err.println("sql_data.executeQuery:" + ex.getMessage());
            }
            return rs;
        }    //插入数据
        public boolean executeInsert(String insert_SQL) throws Exception {
            pstmt = openConnection().prepareStatement(insert_SQL);
            try {
                pstmt.executeUpdate();
                closePreparedStatement();
                closeConnection();
                return true;
            } catch (Exception ex) {
                System.err.println(ex.getMessage());
                closePreparedStatement();
                closeConnection();
                return false;
            }
        }    //更新数据库数据
        public boolean executeUpdate(String update_SQL) throws Exception {
            pstmt = openConnection().prepareStatement(update_SQL);
            try {
                pstmt.executeUpdate();
                closePreparedStatement();
                closeConnection();
                return true;
            } catch (Exception ex) {
                System.err.println("aq.executeQuery: " + ex.getMessage());
                closePreparedStatement();
                closeConnection();
                return false;
            }
        }    //返回布尔值,数据存在为真,否则为假
        public boolean boolData(String bool_SQL) throws Exception {
            pstmt = openConnection().prepareStatement(bool_SQL);
            boolean bool = false;
            ResultSet rs = null;
            try {
                rs = pstmt.executeQuery();
                if(rs.next()) {
                    bool = true;
                } else {
                    bool = false;
                }
            } catch (Exception ex) {
                System.err.println("sql_data.executeQuery:" + ex.getMessage());
                bool = true;
            }
            rs.close();
            closePreparedStatement();
            closeConnection();
            return bool;
        }    //返回记录数
        public int getResultCount(String count_SQL) throws Exception {
            pstmt = openConnection().prepareStatement(count_SQL);
            int icount = 0;
            ResultSet rs = null;
            try {
                rs = pstmt.executeQuery();
                while (rs.next()) {
                    icount = rs.getInt(1);
                }
            } catch(Exception ex) {
                System.err.println("sql_data.executeQuery:" + ex.getMessage());
                icount = 0;
            }
            rs.close();
            closePreparedStatement();
            closeConnection();
            return icount;
        }
    }#################################连接好像都关了呀