Re: Memroy leak with jdbc

From: Barry Lind <blind(at)xythos(dot)com>
To: Joseph Shraibman <jks(at)selectacast(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Memroy leak with jdbc
Date: 2003-05-07 00:08:07
Message-ID: 3EB84E67.2090006@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Joseph,

After rereading the javadoc on Connection.getWarnings(),
Statement.getWarnings() and ResultSet.getWarnings(), I agree with you.

I have a fix ready to checkin for this. It is basically the same as you
are doing below, but using the addWarning(String) method on Statement (I
am not sure why you are trying to add a addWarnings(SQLWarning) method).

thanks,
--Barry

Joseph Shraibman wrote:
> Barry Lind wrote:
>
>> Joseph,
>>
>> The reason this is happening is because this particular select
>> statement is generating a warning message from the server. If you
>> turn on logging in the driver (add ?loglevel=2 to the jdbc URL) you
>> will see the following warning generated for each execution of this
>> sql statement:
>>
>> NOTICE: Adding missing FROM-clause entry in subquery for table "taba"
>>
>> These warning messages are stored up until you read them, or call
>> clearWarnings().
>>
>> This is all correct behavior AFAICT.
>>
> I think the warnings should be added to the Statement or ResultSet, not
> the Connection. I'm trying to hack the cvs version of the driver, but it
> won't compile for some reason.
>
> Here's the patch:
> *** org/postgresql/core/BaseResultSet.java.orig Tue May 6 14:41:13 2003
> --- org/postgresql/core/BaseResultSet.java Tue May 6 14:55:02 2003
> ***************
> *** 46,50 ****
> public void reInit (Field[] fields, Vector tuples, String status,
> int updateCount, long insertOID, boolean
> binaryCursor);
> public void setStatement(BaseStatement statement);
> !
> }
> --- 46,53 ----
> public void reInit (Field[] fields, Vector tuples, String status,
> int updateCount, long insertOID, boolean
> binaryCursor);
> public void setStatement(BaseStatement statement);
> ! /**
> ! * This adds a warning to the warning chain.
> ! */
> ! public void addWarnings(java.sql.SQLWarning warnings);
> }
> *** org/postgresql/core/QueryExecutor.java.orig Tue May 6 14:41:21 2003
> --- org/postgresql/core/QueryExecutor.java Tue May 6 15:08:41 2003
> ***************
> *** 148,154 ****
> int t = pgStream.ReceiveChar();
> break;
> case 'N': // Error Notification
> !
> connection.addWarning(pgStream.ReceiveString(connection.getEncoding()));
> break;
> case 'P': // Portal Name
> String pname =
> pgStream.ReceiveString(connection.getEncoding());
> --- 148,155 ----
> int t = pgStream.ReceiveChar();
> break;
> case 'N': // Error Notification
> !
> //connection.addWarning(pgStream.ReceiveString(connection.getEncoding()));
> !
> statement.addWarnings(new
> java.sql.SQLWarning(pgStream.ReceiveString(connection.getEncoding())));
> break;
> case 'P': // Portal Name
> String pname =
> pgStream.ReceiveString(connection.getEncoding());
>
>
> But when I try to compile, I get:
> -------------------------------------
> /usr/local/ant/bin/ant -buildfile ./build.xml all
> Buildfile: ./build.xml
>
> all:
>
> prepare:
>
> check_versions:
> [available] DEPRECATED - <available> used to override an existing property.
> [available] Build file should not reuse the same property name for
> different values.
>
> check_driver:
>
> driver:
>
> compile:
> [javac] Compiling 53 source files to
> /home/jks/work/pgtemp/pgsql/src/interfaces/jdbc/build
> [javac]
> /home/jks/work/pgtemp/pgsql/src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java:152:
> cannot resolve symbol
> [javac] symbol : method addWarnings (java.sql.SQLWarning)
> [javac] location: interface org.postgresql.core.BaseStatement
> [javac]
> statement.addWarnings(new
> java.sql.SQLWarning(pgStream.ReceiveString(connection.getEncoding())));
> [javac] ^
> [javac] Note: Some input files use or override a deprecated API.
> [javac] Note: Recompile with -deprecation for details.
> [javac] 1 error
>
> BUILD FAILED
> file:/home/jks/work/pgtemp/pgsql/src/interfaces/jdbc/build.xml:108:
> Compile failed; see the compiler error output for details.
>
> Total time: 16 seconds
> make: *** [all] Error 1
> -------------------------------------
> As you can see I did add addWarnings() to the interface, so why is javac
> complaining? This is with java 1.4.1_02. Does anyone know how to use
> jikes with ant(1.5.1)? I've been poking around the documentation, but I
> can't find anything.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message David Wall 2003-05-07 01:11:46 Re: Memroy leak with jdbc
Previous Message Barry Lind 2003-05-06 23:44:48 Re: JDBC 3.0 support?