JDBC – How to get the column name (not the original column name)

I have a query something like this which rename the column name animal to bird.

select animal as bird 
from table;

I want to retrieve the column name bird through Jdbc and not the column name animal. When I do

Connection cn = DriverManager.getConnection(host,username,password);
Statement st = cn.createStatement();
ResultSet resultset = statement.executeQuery(query);

I get the original column name instead of the renamed column name. How can I get the renamed column name?


There are two functions:


The name function will give you the actual column name of the CREATE TABLE statement.



The label function will give you the renamed column name.

So in your case you have to go for the getColumnLabel() function 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *