tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "prakash shanmugam" <>
Subject how to over come toomanyconnection error when communicatingMYSQL
Date Fri, 11 Aug 2006 06:39:39 GMT
hai all,
i have one major issue in my project..
My project is developed using jsp,servlets in Tomcat5 with MySql as
database.. i am using type1 driver
My project is now used by end users in intranet..
When multiple users are accessing at the same time ,its throwing too many
connections exception at sometimes . And at sometimes its dispaying error as
"Operation not allowed after ResultSet is closed"
i dont know how to rectify this .. Can anybody help me to overcome this..
Here is my bean file used for establing database connections...
package com.pts.database;
import java.sql.*;
public class DBCon
private static final String DriverClass = "com.mysql.jdbc.Driver";
private static final String CONNECTION_STRING = "jdbc:mysql://";
private static final String PORT = "3306";
private static final String DATABASE = "opts";
private static final String user = "dav";
private static final String pwd="";
private static Connection con = null;
private static Statement stmt = null;
private static Statement stmt2 = null;
private static PreparedStatement pst = null;
private static ResultSet rs = null;
private static int count = 0;
public static void assignCon()
catch(ClassNotFoundException ce){System.out.println(ce);}
catch(InstantiationException ie){}
catch(IllegalAccessException ie1){}

con = DriverManager.getConnection
stmt = con.createStatement();
stmt2 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
}catch(SQLException sqle){System.out.println("STMT:"+sqle);}
public static ResultSet retrieveFromDB(String sql) throws SQLException
return (stmt.executeQuery(sql));
public static ResultSet retrieveScrollDB(String sql) throws SQLException
return (stmt2.executeQuery(sql));
public static int updateDB(String sql) throws SQLException
return (stmt.executeUpdate(sql));
public static PreparedStatement prepareStmt(String sql) throws SQLException{
return pst;
public static ResultSet getProjectsList() throws SQLException{
rs=((PreparedStatement)con.prepareStatement("select projID,projName from
proj_det where delFlag=0 || delFlag IS NULL")).executeQuery();
return rs;
public Connection getConn() {
return con;
public Statement getStmt()
return stmt;
public static void CloseAll() throws SQLException

Hope Any of u can help me.. it would be very much helpful to me if any body
suggest me a solution to this... Because of this issue my project is in

Thanks in Advance

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message