Forum Stats

  • 3,876,067 Users
  • 2,267,054 Discussions
  • 7,912,418 Comments

Discussions

Can't Solve the "Too Many Clients Tasks" Problem

843810
843810 Member Posts: 46,938
Hello All ,

I am creating a java desktop application , and i keep getting this error message:

[Microsoft][ODBC Microsoft Access Driver] Too many client tasks.


Any way ,i googled for this error and i found that because i creates many connections with database "more than 10 i think " , and that why i get this error message ..


The problem is that i do not know how to solve it , i tried to close the connections and i still getting the same error

I searched this forum , and someone suggest to close the connections and the statements and the resultset , but still not working

this is the code
public class Database_Mangement {

    private String User_ID;
    private String  user_name;
    private String password;
    private Admin_Connection c;
    private Connection conn;
    private Connection uni_conn;
    private ArrayList<Admin_TableEntry> data;
    

    public Database_Mangement() throws SQLException
    {
      conn = null;
      uni_conn = null;
      conn = DriverManager.getConnection("jdbc:odbc:smart_database");// Connect with database no 1 through ODBC
      uni_conn = DriverManager.getConnection("jdbc:odbc:uni_database");//Connect with database no 2 through ODBC
      data = new ArrayList<Admin_TableEntry>();
    }
 
     ArrayList<Admin_TableEntry> getInformation(int type)throws SQLException
     {
         Statement stm = null;
         ResultSet getInfo = null;
       try{
         //get User Information
            
            if(type==1)
            {
                 stm = conn.createStatement();
                String temp;
                temp = "select * from Students";
                getInfo = stm.executeQuery(temp);
            }
            else if(type==2)
            {
                 stm = uni_conn.createStatement();
                String temp;
                temp = "select * from Students";
                getInfo = stm.executeQuery(temp);
            }
             
            
           
             while(getInfo.next())
             {
                  Admin_TableEntry tempclass = new Admin_TableEntry();
                  if(type==1)
                  {tempclass.ID = getInfo.getString("Student_ID");
                   tempclass.Name =getInfo.getString("Student_Name");
                   tempclass.balance=getInfo.getString("Student_Balance");}
                  else if(type==2)
                  {
                      tempclass.ID =getInfo.getString("Student_ID");
                      tempclass.Name = getInfo.getString("First_Name");
                      tempclass.Last_Name =getInfo.getString("Last_Name");
                      tempclass.haveaccount=getInfo.getBoolean("Have_SmartCard");
                  }
                   
                   data.add(tempclass);
           }
      }
catch(Exception e)
{System.out.println(e.getMessage();}
 finally
 {
     conn.close();
     uni_conn.close();
    stm.close();
//    getInfo.close();  Please note that i get an error message when i try to close the ResultSet
//and this is the error message
// Exception in thread "main" java.sql.SQLException: ResultSet is closed


 }
 


               return data;

     }

}
and thank you for your time..

Comments

  • jschellSomeoneStoleMyAlias
    jschellSomeoneStoleMyAlias Member Posts: 24,877 Gold Badge
    Close the result set first, then ththe statement, then the connections.

    That particular error message is in reference to too many applications on a box trying to access the database. So are you leaving orphaned processes running?
  • 843810
    843810 Member Posts: 46,938
    Thanks , but it only solved the ResultSet.close() problem ,

    i am still getting the Too Many Clients error


    and i am closing every connection i created after the end of every function .


    i think i will switch to SQl server 2008 ... Hope it will be better
  • dadams07
    dadams07 Member Posts: 1,310
    I'd be surprised if changing databases solves the problem. The problem as others said, is that some database resource is not getting released - the classic resource leak find out where you're failing to release something & the problem will go away.
This discussion has been closed.