With java.sql.ResultSet
is there a way to get a column's name as a String
by using the column's index? I had a look through the API doc but I can't find anything.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
In addition to the above answers, if you're working with a dynamic query and you want the column names but do not know how many columns there are, you can use the ResultSetMetaData object to get the number of columns first and then cycle through them.
Ammending Brian's code:
Using getMetaData();
EDIT: This works with PostgreSQL as well
Table Name : person Field DataType id VARCHAR cname VARCHAR dob DATE