Re: JDBC Question: Getting data from tables with columns that have the same name
- From: Thomas Kellerer <WVIJEVPANEHT@xxxxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 08:18:25 +0200
On 30.06.2005 03:35 lennyw wrote:
> I'm making a JDBC SQL query that looks something like this:
>
> select <a bunch of columns>, a.shortcode, <some more coumns>,
> z.shortcode from Table1 a, Table2 b, Table3 z where <join conditions>,
> <more conditions>
>
> I get reasonable values in my JDBC result set.
>
> I've been trying to extract the two "shortcode" column data items that
> came from Table1 and Table3 from my result set rows with calls like:
>
> String st1 = new String();
> String st2 = new String();
> st1 = rs.getString("a.shortcode");
> st2 = rs.getString("z.shortcode");
Simply give them a column alias:
SELECT <bunch>, a.shortcode as a_shortcode, z.shortcode as z_shortcode
FROM ....
st1 = rs.getString("a_shortcode"),
st2 = rs.getString("z_shortcode");
> String st1 = new String();
> String st2 = new String();
Why do you do that? You create a new object just to throw it away in the next
line (when you assign a new value to the variable).
This is not needed.
Thomas
.
- Follow-Ups:
- References:
- Prev by Date: Re: RefCursor works in SQL*Plus but not JDBC
- Next by Date: Re: Looking for DB advice
- Previous by thread: Re: JDBC Question: Getting data from tables with columns that have the same name
- Next by thread: Re: JDBC Question: Getting data from tables with columns that have the same name
- Index(es):
Relevant Pages
|
|