Spring JDBC SqlRowSet retrieve with non-unique column label -



Spring JDBC SqlRowSet retrieve with non-unique column label -

spring's sqlrowset has string getstring(string columnlabel)

but if query joins 2 tables have same column name, result set have non-unique column labels.

for example:

select a.name, b.name bring together b on a.id=b.id

and after running query , populating sqlrowset object, call.

for example:

sqlrowset.getstring("name")

will homecoming me a.name, or b.name?

trying specific, using:

sqlrowset.getstring("a.name")

will throw error

if have non-unique names, either need assign unique labels using as clause, or need retrieve columns index instead.

using as (note as - in database systems - optional):

class="lang-sql prettyprint-override">select a.name aname, b.name bname bring together b on a.id=b.id class="lang-java prettyprint-override">sqlrowset.getstring("aname")

by index. retrieve a.name:

class="lang-java prettyprint-override">sqlrowset.getstring(1)

jdbc spring-jdbc

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -