Thread: Anoter JDBC Error

Anoter JDBC Error

From
Aaron Mulder
Date:
    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


Re: Anoter JDBC Error

From
Kris Jurka
Date:
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@postgresql.org so that your
> message can get through to the mailing list cleanly
>

Attachment

Re: [PATCHES] Anoter JDBC Error

From
Barry Lind
Date:
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@postgresql.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@postgresql.org)
>