Reputation: 107
I want to know how to get the column count of resulting output in MySQL.
I searched this site for the same question but i'm little different.
I want to get the column count of resulting output not of the table.
I want to know how many columns are there in the resulting output when a query is passed.
Thanxx in advance!
Upvotes: 1
Views: 3426
Reputation: 1
you don´t need a ResultSetMetaData
variable, just try this code:
int columCount = rs.getMetaData().getColumnCount();
the rs
is a Resulset
.
Upvotes: 0
Reputation: 5183
Use ResultSetMetaData#getColumnCount() method to get the count in java
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
Upvotes: 1
Reputation: 3212
ResultSetMetaData metadata = resultSet.getMetaData();
int columnCount = metadata.getColumnCount();
Upvotes: 1