You can get columns number from ResultSetMetaData:
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
int columnsNumber = rsmd.getColumnCount();
More Related Contents:
- How do I get the size of a java.sql.ResultSet?
- Getting java.sql.SQLException: Operation not allowed after ResultSet closed
- When to close Connection, Statement, PreparedStatement and ResultSet in JDBC
- JDBC driver throws “ResultSet Closed” exception on empty ResultSet
- JDBC ResultSet get columns with table alias
- Execute anonymous pl/sql block and get resultset in java
- ResultSet: Retrieving column values by index versus retrieving by label
- ResultSet.getString(1) throws java.sql.SQLException: Invalid operation at current cursor position
- How to get row count using ResultSet in Java?
- How do I get the row count in JDBC?
- Convert a Result Set from SQL Array to Array of Strings
- Efficient way to do batch INSERTS with JDBC
- What is the actual use of Class.forName(“oracle.jdbc.driver.OracleDriver”) while connecting to a database?
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications link failure [duplicate]
- java.sql.SQLException: Exhausted Resultset
- CSV parsing in Java – working example..? [closed]
- Parsing CSV in java
- Getting an exception ORA-00942: table or view does not exist – when inserting into an existing table
- ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp error
- oracle.jdbc.driver.OracleDriver ClassNotFoundException
- Populating jTable using database data
- How to simulate a DB for testing (Java)?
- Cannot find Main Class in File Compiled With Ant
- Using a prepared statement and variable bind Order By in Java with JDBC driver
- ResultSet: Exception: set type is TYPE_FORWARD_ONLY — why?
- Reading CSV File In Android App
- Resultset To List
- How do you enforce foreign key constraints in SQLite through Java?
- How to connect to a remote MySQL database with Java?
- How to get jdbc connection from hibernate session? [duplicate]