Reading columns in recordset row in different order 
Author Message
 Reading columns in recordset row in different order

With Java, on setting up a recordset using the
default parameters, I have found that I can only
read columns in the order they appear in the
query result.

Therefore, the following statement would work :

System.out.println(rs.getString(1) + rs.getString
(2)+ rs.getString(3));

... but this would not :

System.out.println(rs.getString(1) + rs.getString
(3)+ rs.getString(2));

Is there a way of making the second statement
work??

(I have tried setting different parameters on the
statement, e.g.
ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR
_UPDATABLE, but these have given run-time errors,
so I don't know if this is the solution).

Please help.

Sent via Deja.com http://www.***.com/
Before you buy.



Tue, 23 Apr 2002 03:00:00 GMT
 Reading columns in recordset row in different order

With Java, on setting up a recordset using the default parameters, I
have found that I can only read columns in the order they appear in the
query result.

Therefore, the following statement would work :

System.out.println(rs.getString(1) + rs.getString(2)+ rs.getString(3));

... but this would not :

System.out.println(rs.getString(1) + rs.getString(3)+ rs.getString(2));

Is there a way of making the second statement work??

(I have tried setting different parameters on the statement, e.g.
ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE, but these
have given run-time errors, so I don't know if this is the solution).

Please help.

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 23 Apr 2002 03:00:00 GMT
 Reading columns in recordset row in different order
With Java, on setting up a recordset using the default parameters, I
have found that I can only read columns in the order they appear in the
query result.

Therefore, the following statement would work :

System.out.println(rs.getString(1) + rs.getString(2)+ rs.getString(3));

... but this would not :

System.out.println(rs.getString(1) + rs.getString(3)+ rs.getString(2));

Is there a way of making the second statement work??

(I have tried setting different parameters on the statement, e.g.
ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE, but these
have given run-time errors, so I don't know if this is the solution).

Please help.

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 23 Apr 2002 03:00:00 GMT
 Reading columns in recordset row in different order
Try this....

String s1 = rs.getString(1);
String s2 = rs.getString(2);
String s3 = rs.getString(3);

System.out.println(s1 + s3 + s2);

I'm betting you are using jdbc-odbc. There is a column cursor for that,
and once you advance past a column, you cant move the cursor backwards,
and you'll get errors if you try.

--Sunil

Quote:

>With Java, on setting up a recordset using the
>default parameters, I have found that I can only
>read columns in the order they appear in the
>query result.

>Therefore, the following statement would work :

>System.out.println(rs.getString(1) + rs.getString
>(2)+ rs.getString(3));

>... but this would not :

>System.out.println(rs.getString(1) + rs.getString
>(3)+ rs.getString(2));

>Is there a way of making the second statement
>work??

>(I have tried setting different parameters on the
>statement, e.g.
>ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR
>_UPDATABLE, but these have given run-time errors,
>so I don't know if this is the solution).

>Please help.

>Sent via Deja.com http://www.deja.com/
>Before you buy.



Tue, 23 Apr 2002 03:00:00 GMT
 Reading columns in recordset row in different order
  I read resultsets by moving them to a vector for temp storage.  Then
I do whatever I need with the vector.  While I haven't needed to
access the columns out of order I ran  into a problem with needing to
access a given row of the recordset more than once and discovered some
drivers couldn't.  The temp storage approach solved that one.

Quote:

>With Java, on setting up a recordset using the
>default parameters, I have found that I can only
>read columns in the order they appear in the
>query result.

>Therefore, the following statement would work :

>System.out.println(rs.getString(1) + rs.getString
>(2)+ rs.getString(3));

>... but this would not :

>System.out.println(rs.getString(1) + rs.getString
>(3)+ rs.getString(2));

>Is there a way of making the second statement
>work??

>(I have tried setting different parameters on the
>statement, e.g.
>ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR
>_UPDATABLE, but these have given run-time errors,
>so I don't know if this is the solution).

>Please help.

>Sent via Deja.com http://www.deja.com/
>Before you buy.

--------
To send me email remove "REMOVETHIS" from my address.


Wed, 24 Apr 2002 03:00:00 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. Joining and ordering different recordsets into 1 recordset

2. how to establish referntial integraty of a column with two different columns of different tables

3. Selecting all columns, but in a different order in SELECT statement

4. order by where values are in different columns

5. Could not do a physical-order read to fetch next row

6. ORDER BY clause causes read-only recordset

7. *** ListView Items on one row - different columns

8. Multiplying columns from different rows

9. SP - Only select columns which names are in a different recordset

10. Order Recordset By Smalldatetime Column Containing Nulls

11. Order of columns in a recordset

12. Ordering Rows based on Values in a column


 
Powered by phpBB® Forum Software