![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e254. Getting the Column Names in a Result Settry { // Create a result set Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM my_table"); // Get result set meta data ResultSetMetaData rsmd = rs.getMetaData(); int numColumns = rsmd.getColumnCount(); // Get the column names; column indices start from 1 for (int i=1; i<numColumns+1; i++) { String columnName = rsmd.getColumnName(i); // Get the name of the column's table name String tableName = rsmd.getTableName(i); } } catch (SQLException e) { }
e252. Getting Data from a Result Set e253. Determining If a Fetched Value Is NULL e255. Getting the Number of Rows in a Database Table e256. Getting BLOB Data from a Database Table e257. Matching with Wildcards in a SQL Statement © 2002 Addison-Wesley. |