ringa_lee2017-04-18 09:18:25
Isn’t it enough to directly use the sql statement select * from tableName... Use the next() method to iterate...
高洛峰2017-04-18 09:18:25
The method is mentioned above. The next() method is to get one row of data at a time. If not, it returns false, so you can get all the data with while(rs.next())
巴扎黑2017-04-18 09:18:25
1. Query all the data in the table: SELECT * FROM table
;
2、使用JDBC提供的java.sql.ResultSetMetaData
The class can obtain the number of columns contained in the query result and the name of each column (ColumnLabel) in the query result set;
As mentioned above, use next() to traverse the result set .
ringa_lee2017-04-18 09:18:25
SELECT * The data queried from the database is divided into rows.
while(rs.next()) can be seen as determining whether there is a next line.
java.sql.ResultSet provides a method to get columns, rs.getString(1). (Columns are numbered from left to right and start at column 1)