Hi,

It seems in the code that you try to create a new database pool within
SupportingClass.getDbresults();

The myBroker variable needs to be created only once, during servlet's
init() stage.

Then pass it as an argument to SupportingClass constructor or
getDbResults(), and use it only to getConnection() and freeConnection()
more than once.

Otherwise, each time you create an DbConnectionBroker it will try to
open at least one connection.

Cezar.
---------------------------------------------------
Serving coffee on aircraft causes turbulence.

On Sun, 25 Jul 1999, Dean wrote:

> Hi All
>
> My Setup:
> Redhat5.2, Jrun, Apache1.3.4, Postgresql6.4.2, jdk1.1.7b from blackdown
>
> Problem:
> Ok, Im using DbConnectionBroker to handle my database
> requests as is good practice. Everything works fine except
> postgres seems to spawn threads of itself for every request and
> doesnt close them again - even though i close the resultset, statement
> and free my connection with DbConnectionBroker
>
> Some Code:
>
> class MyServlet {
>
>   public void init(blah) {
>     //..blah
>     //..Have tried DBConnection in here - same result though??
>   }
>
>
>  public void doGet(HttpServletRequest req, HttpServletResponse res)
>      throws ServletException, IOException {
>
>
>        SupportingClass sp = new SupportingClass()
>         out,println(sp.getDBResults(someparameter));
>    }
>
>
> //Something like this..
> class SupportingClass {
>
>     public StringBuffer getDBResults(someparameter) {
>         DbConnectionBroker myBroker;
>         Connection con;
>
>         int key;
>         StringBuffer WH_sb = new StringBuffer();
>
>        if (con == null) {
>
> 
>DbConnectionBroker("postgresql.Driver","jdbc:postgresql://127.0.0.1:5432/somedatabase","username","passwd");
>
>            con = myBroker.getConnection();
>        }
>
>        Statement st = con.createStatement();
>        ResultSet rs = st.executeQuery("Select somestuff from a
> database");
>
>        Hashtable db_result = Result(rs);
>
>        for (key=0;key<db_result.size(); key++) {
>            Vector I_name = (Vector)db_result.get(new Integer(key))
>            String I_index=(String)I_name.elementAt(0);
>            String I_ingredient= (String)I_name.elementAt(1);
>             WH_ sb.append(I_index);
>             / /etc
>         }
>         st.close();
>        rs.close();
>        myBroker.freeConnection(con);
>         return WH_sb;
>     }
> }
>
> What gives ??? - anyone got an idea?
>
> Thanks
> Dean
> [EMAIL PROTECTED]
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to