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):
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
:
sqlrowset.getstring(1)
jdbc spring-jdbc
Comments
Post a Comment