As the ResultSet contains the data returned from the dynamic SQL, if there are any method to determine if the ResultSet contains a particular column name ? For example , if I run rs.getString("Column_ABC");
but Column_ABC does not really exist, it will throw out the exception . How can I test if the ResultSet can get a data from a column named "Column_ABC" ?
相关问题
- 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 java version >=7 you have a option of passing Class type in ResultSet#getObject method
if not rs.getString("Column_ABC")= nothing then ' your code here
Not sure if this is more or less efficient than Erick's answer but it's easier.
Use the
ResultSetMetaData
class.The thing I don't understand is why this function would ever be needed. The query or stored procedure being executed should have known results. The columns of the query should be known. Needing a function like this may be a sign that there is a design problem somewhere.