pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: pg@fastcrypt.com
Cc: pgsql-jdbc@postgresql.org
Subject: Re: BIGINT <-> java.lang.String auto cast
Date: Fri, 27 May 2005 01:04:33 +0000
Message-ID: <42967221.20505@opencloud.com> (raw)
In-Reply-To: <42966D6E.1080007@fastcrypt.com>
References: <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAABJc9hR3hbE6zRuQKvBNvsIKAAAAQAAAA0LbZy9jzwkqkZHEP9P+p2wEAAAAA@xtech.ru>
	<4294BAAE.4080106@fastcrypt.com>
	<42955CC9.6040306@opencloud.com>
	<4295B69E.1070308@fastcrypt.com>
	<42965917.7090206@opencloud.com>
	<4296675D.6060505@fastcrypt.com>
	<42966881.2000609@opencloud.com>
	<42966D6E.1080007@fastcrypt.com>

Dave Cramer wrote:
> Where do you see the driver doing such conversions.

In AbstractJdbc2Statement.setObject(int,Object,int,int), e.g.:

>     // Helper method that extracts numeric values from an arbitary Object.
>     private String numericValueOf(Object x)
>     {
>         if (x instanceof Boolean)
>             return ((Boolean)x).booleanValue() ? "1" : "0";
>         else if (x instanceof Integer || x instanceof Long ||
>                  x instanceof Double || x instanceof Short ||
>                  x instanceof Number || x instanceof Float)
>             return x.toString();
>         else
>             //ensure the value is a valid numeric value to avoid
>             //sql injection attacks
>             return new BigDecimal(x.toString()).toString();
>     }

[...]

>         switch (targetSqlType)
>         {
>         case Types.INTEGER:
>             bindLiteral(parameterIndex, numericValueOf(x), Oid.INT4);
>             break;

[...]

-O



view thread (14+ messages)  latest in thread

Message-ID: <42967221.20505@opencloud.com>
Permalink:  ../42967221.20505@opencloud.com/
Also on:    postgresql.org/message-id/42967221.20505@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, pg@fastcrypt.com
  Subject: Re: BIGINT <-> java.lang.String auto cast
  In-Reply-To: <42967221.20505@opencloud.com>
  References: <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAABJc9hR3hbE6zRuQKvBNvsIKAAAAQAAAA0LbZy9jzwkqkZHEP9P+p2wEAAAAA@xtech.ru> <4294BAAE.4080106@fastcrypt.com> <42955CC9.6040306@opencloud.com> <4295B69E.1070308@fastcrypt.com> <42965917.7090206@opencloud.com> <4296675D.6060505@fastcrypt.com> <42966881.2000609@opencloud.com> <42966D6E.1080007@fastcrypt.com> <42967221.20505@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox