java - PostgreSQL- getColumnName is not working, returning alias Name -


i'm trying column name below query,

select     category c1,     forecast_2016,     category,     rowcount,     item_number,     rowcount,     category,     avg_demand_2014_2015,     category,     avg_spend_2014_2015,     avg_demand_2014_2015,     avg_spend_2014_2015,     demand_2015     ag_instrument_portfolio_master limit 1 

postgres version 9.3 , java version 1.7, java implementation below.

stmt = con.createstatement(); rs = stmt.executequery(query.tostring()); resultsetmetadata columnsmetadata = rs.getmetadata(); int = 0; while (i < columnsmetadata.getcolumncount()) {     i++;     system.out.println("name: " + columnsmetadata.getcolumnname(i));     system.out.println("label: " + columnsmetadata.getcolumnlabel(i)); } 

the output

name: c1 label: c1 

but, expected is

name: category label: c1 

given comment in pgsql-jdbc mailing list here, appears you're seeing "as designed" behaviour of postgresql jdbc driver:

this limitation of information driver gets server, returns 'label' driver uses both columnname , label.

as many other aspects of jdbc, behaviour of given feature can vary depending on implementation of specific jdbc driver.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -