Re: [PATCHES] Anoter JDBC Error

From: Barry Lind <barry(at)xythos(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: Aaron Mulder <ammulder(at)alumni(dot)princeton(dot)edu>, PostgreSQL JDBC <pgsql-jdbc(at)postgresql(dot)org>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [PATCHES] Anoter JDBC Error
Date: 2002-10-19 22:13:52
Message-ID: 3DB1D920.2040801@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc pgsql-patches

Patch applied.

--Barry

Kris Jurka wrote:
> This is doing a getInt on a field with a value of the empty string. The
> application will still get an error after this patch, but it will be more
> obvious where the error is coming from.
>
> This patch also fixes a problem when retrieving negative monetary values.
>
> On Wed, 9 Oct 2002, Aaron Mulder wrote:
>
>
>> Haven't had a chance to look into this one yet -- came up in
>>DBVis, while looking for the columns for a new table, so it's probably
>>another DBMD query. Something assuming a String won't be empty?
>>
>>java.lang.StringIndexOutOfBoundsException: String index out of range: 0
>> at java.lang.String.charAt(String.java:460)
>> at org.postgresql.jdbc1.AbstractJdbc1ResultSet.getFixedString(AbstractJdbc1ResultSet.java:650)
>> at org.postgresql.jdbc1.AbstractJdbc1ResultSet.getInt(AbstractJdbc1ResultSet.java:144)
>>
>> BTW, thanks for the ' fix.
>>
>>Aaron
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 3: if posting/reading through Usenet, please send an appropriate
>>subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
>>message can get through to the mailing list cleanly
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>Index: src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
>>===================================================================
>>RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java,v
>>retrieving revision 1.6
>>diff -c -r1.6 AbstractJdbc1ResultSet.java
>>*** src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java 2002/09/06 21:23:06 1.6
>>--- src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java 2002/10/11 23:02:46
>>***************
>>*** 646,651 ****
>>--- 646,655 ----
>> if (wasNullFlag)
>> return null;
>>
>>+ // if we don't have at least 2 characters it can't be money.
>>+ if (s.length() < 2)
>>+ return s;
>>+
>> // Handle Money
>> if (s.charAt(0) == '(')
>> {
>>***************
>>*** 654,659 ****
>>--- 658,667 ----
>> if (s.charAt(0) == '$')
>> {
>> s = s.substring(1);
>>+ }
>>+ else if (s.charAt(0) == '-' && s.charAt(1) == '$')
>>+ {
>>+ s = "-" + s.substring(2);
>> }
>>
>> return s;
>>
>>
>>------------------------------------------------------------------------
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 2: you can get off all lists at once with the unregister command
>> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Aaron Mulder 2002-10-19 22:28:48 Re: [PATCHES] Anoter JDBC Error
Previous Message Barry Lind 2002-10-19 20:31:35 Re: Getting a ResultSet for a refcursor element.

Browse pgsql-patches by date

  From Date Subject
Next Message Aaron Mulder 2002-10-19 22:28:48 Re: [PATCHES] Anoter JDBC Error
Previous Message Tom Lane 2002-10-19 22:12:21 Re: PL/Python memory leak (Replaces earlier patch from today)