I want get concatenated citycode-hotelcode pair from the cityHotelData Table.
(citycode and hotelcode are varchar in cityHotelData Table)
When I am running following query using phpPgAdmin it works fine.
select citycode || '-' || hotelcode from cityHotelData
But when I am running it in java using JDBC it gives following error.
org.postgresql.util.PSQLException: The column name citycode || '-' || hotelcode was not found in this ResultSet.
I am using PostgreSQL 8.0.26.
Java Code :
Connection conn = DriverManager.getConnection(ConnString,ConnUser,ConnPassword);
public ResultSet executeStatementQuery(String sql) throws Exception {
this.qry = sql;
try {
stmt = conn.createStatement(); // Statement stmt
rs = stmt.executeQuery(sql); //ResultSet rs
} catch (SQLException sqlEx) {
sqlEx.printStackTrace();
closeResultSet();
} catch (Exception cnfe) {
closeResultSet();
cnfe.printStackTrace();
}
return rs;
}
Try this:
EDIT:
To exclude any Java issues, try using this Java code: