List:MySQL and Java« Previous MessageNext Message »
From:Christian Mack Date:September 14 1999 7:35pm
Subject:Re: Interesting process problem
View as plain text  
rmccown@stripped wrote:
> 
> Hi there.
>  Ive got an interesting problem happening here.  Im using java 1.2, Apache
> 1.3.x, and Linux 2.1.35.  Im writing a servlet, and using the following
> style of call to send a query:
> 
>    try {
>       Connection con = DriverManager.getConnection(SQL_DBURL);
>       Statement stmt = con.createStatement();
>       String sQuery = "Select email, addrlist from users where userid='" +
> iUserID + "'";
>       ResultSet rs = stmt.executeQuery(sQuery);
>       if( rs.next() )
>       {
>         ...
> 
> what happens, is EVERY TIME that a request is executed, I get another
> process of mysql running.  here's the ps -auxw of one of the lines:
> 
> root   388  0.0  3.2  18976  1500  ?  S  N  14:33  0:00
> /usr/local/mysql-3.22.25-pc-linux-gnu-i686/bin/mysqld
> --basedir=/usr/local/mysql-3.22.25-pc-linux/gnu-i386
> --datadir=/usr/local/mysql/data --skip-locking --user=root
> --pid-file=/usr/local/mysql/data/goodolboys.pic
> --datadir=/usr/local/mysql/data
> 
> Over the span of a couple hours, I get hundreds of these, and eventually the
> machine grinds to a halt.
> 
> Any ideas?
> 
> -Bob

Hi Bob

These "processes" are actually threads.
And mysql creates one thread per connection.
Under Linux ps shows them as processes (bug!?).

But your problem seems to me, that you don't close your connections after use!!!!
Add:
    finally {
        try {
            rs.close();
        }
        catch (Exception e) {
        }
        try {
            stmt.close();
        }
        catch (Exception e) {
        }
        try {
            con.close();
        }
        catch (Exception e) {
        }
    }

To your servlet.

Tschau
Christian

Thread
Interesting process problemrmccown14 Sep
  • Re: Interesting process problemMark Matthews14 Sep
  • Re: Interesting process problemChristian Mack14 Sep