3 messages in com.mysql.lists.javaRunning out of threads using getObjec...
FromSent OnAttachments
aki...@earthlink.net08 Apr 2004 08:19 
Mark Matthews08 Apr 2004 08:45 
aki...@earthlink.net08 Apr 2004 08:56 
Subject:Running out of threads using getObject() on a BLOB
From:aki...@earthlink.net (aki@earthlink.net)
Date:04/08/2004 08:19:48 AM
List:com.mysql.lists.java

Hi,

I've tried searching everywhere for why this happens, but I'm having no luck.
It might just be something silly on my part =). It seems that whenever I do
rs.getObject("value"), it keeps creating a new thread until eventually I just
run out of threads. Thanks in advance.

I've created the tables using the following sql statement: "CREATE TABLE " + tableName + " (keycol MEDIUMBLOB, value MEDIUMBLOB, hashKey
INTEGER)"

The following method is used to populate the table: /** * Description of the Method * *@param arg0 Description of the Parameter *@param arg1 Description of the Parameter *@return Description of the Return Value */ public Object put(Object arg0, Object arg1) { Object result = null; if (userSelection.value() == DBHashMapValues.HASMAPONLY.value()) { //use HASMAP result = mHashMap_.put(arg0, arg1); return result; } else if (userSelection.value() == DBHashMapValues.DBHASMAP_HASMAP.value()) { //USE HASMAP and DBHASHMAP //Here we need to check what user wants to do?? //let's use loadBalRules object which user implements. //If it's return false means user don't want to store object in data base. //let's store in HashMap and return. if (!loadBalRules.isStoreInDB(this, arg1)) { //check if anything in database. try { selectRowpsmt.setInt(1, arg0.hashCode()); ResultSet chkrs = selectRowpsmt.executeQuery(); if (chkrs.next()) { //need to delete from database. remove(arg0); } } catch (SQLException e) { m_logger.error("put() " + e.toString()); } result = mHashMap_.put(arg0, arg1); return result; } } //used for DBHASHMAP and (DBHASMAP_HASMAP) if (arg0 != null && arg1 != null && arg0 instanceof Object && arg1 instanceof Object) { ResultSet rs = null; try { selectRowpsmt.setInt(1, arg0.hashCode()); rs = selectRowpsmt.executeQuery(); if (rs.next()) { //Exist updateRowpsmt.setObject(1, arg0, Types.OTHER); //key updateRowpsmt.setObject(2, arg1, Types.OTHER); //value updateRowpsmt.setInt(3, arg0.hashCode()); //hashKey updateRowpsmt.executeUpdate(); } else { //Add addpsmt.setObject(1, arg0, Types.OTHER); //Key addpsmt.setObject(2, arg1, Types.OTHER); //value addpsmt.setInt(3, arg0.hashCode()); //hashKey addpsmt.executeUpdate(); } } catch (SQLException e) { m_logger.error("put() " + e.toString()); } finally { if (rs != null) { try { rs.close(); } catch (SQLException e1) { m_logger.error("put() " + e1.toString()); } } try { conn.commit(); } catch (SQLException e2) { m_logger.error("put() " + e2.toString()); } } } return result; }

The following method is used to get the data:

/** * Description of the Method * *@param arg0 Description of the Parameter *@return Description of the Return Value */ public Object get(Object arg0) { Object result = null; if (userSelection.value() == DBHashMapValues.HASMAPONLY.value()) { //use HASMAP result = mHashMap_.get(arg0); return result; } else if (userSelection.value() == DBHashMapValues.DBHASMAP_HASMAP.value()) { //USE HASMAP and DBHASHMAP //check first in HASHMAP if it available then don't need to check in database result = mHashMap_.get(arg0); if (result != null) { return result; } } //used for DBHASHMAP and (DBHASMAP_HASMAP) if (arg0 != null && arg0 instanceof Object) { ResultSet rs = null; try { selectRowpsmt.setInt(1, arg0.hashCode()); rs = selectRowpsmt.executeQuery(); if (rs.next()) { result = rs.getObject("value"); } } catch (SQLException e) { m_logger.error("get() " + e.toString()); } finally { try { if (rs != null) { rs.close(); } } catch (SQLException e1) { m_logger.error("get() " + e1.toString()); } try { conn.rollback(); } catch (SQLException e2) { m_logger.error("get() () " + e2.toString()); } } } return result; }