From: | Barry Lind <blind(at)xythos(dot)com> |
---|---|
To: | Richard Welty <rwelty(at)averillpark(dot)net> |
Cc: | "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: examples of SQL Arrays and jdbc? |
Date: | 2003-02-08 03:25:45 |
Message-ID: | 3E4478B9.90001@xythos.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Richard,
The current implementation of setObject() doesn't support arrays.
thanks,
--Barry
Richard Welty wrote:
> On 06 Feb 2003 20:27:19 -0500 Dave Cramer <Dave(at)micro-automation(dot)net> wrote:
>
>
>>Yes, in general any postgres data type can be set/get using
>>setString/getString
>>
>>This may change in the future, it is really an artifact of the wire
>>protocol
>>
>>Be warned!
>
>
> taking this advice to heart, i switched my code to write jdbc int arrays
> from using strings, per eric's posting, to using Integer arrays, saving
> them with setObject, per page 266-267 of the sun jdbc book (second
> edition). their example shows an array of strings:
>
> String [] departments = {"accounting", "personal", "marketing"};
> PreparedStatement pstmt = con.prepareStatement(
> "UPDATE AJAX_LTD SET DEPTS = ? WHERE ID = 0045");
> pstmt.setObject( 1, departments);
>
> my code differs in that the object is an Integer [],
>
> Debug.println( "starting arrays, field_index: " + field_index);
> statement.setObject( ++field_index,
> intArrayToInteger( target_percentages));
> Debug.println( "first array done, field_index: " + field_index);
>
> where intArrayToInteger appears to work correctly, and is as follows:
>
> public static Integer [] intArrayToInteger( int [] ints){
> Integer [] IntArray = new Integer [ints.length];
>
> for( int i = 0; i < ints.length; i++){
> IntArray[i] = new Integer( ints[i]);
> }
> return IntArray;
> }
>
> i'm getting the following error:
>
> starting arrays, field_index: 7
> SQLException: The table for [Ljava.lang.Integer;
> is not in the database. Contact the DBA, as the
> database is in an inconsistent state.
>
> i'd previously seen this when i mistakenly tried to pass int [] arrays to
> setObject. am i missing something here? perhaps some Objects work and not
> others?
>
> environment (which i inadvertantly left out of my note earlier today on my
> problems with set methods on my UPDATE statement):
>
> RedHat 7.3
> postgresql installed from rpm, 7.2.1-5
> pgjdbc2.jar driver from website late october of last year
> jdk 1.4.1_01
>
> thanks in advance,
> richard
> --
> Richard Welty rwelty(at)averillpark(dot)net
> Averill Park Networking 518-573-7592
> Unix, Linux, IP Network Engineering, Security
>
>
>
> ---------------------------(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)
>
From | Date | Subject | |
---|---|---|---|
Next Message | Barry Lind | 2003-02-08 03:34:27 | Re: PreparedStatement.executeBatch() error? 7.3 |
Previous Message | Barry Lind | 2003-02-08 03:19:36 | Re: debugging prepared statements |