Results 1 to 1 of 1
Thread: Getting names of table columns
-
Getting names of table columns
Sometimes getting names of the table columns is required. The code snippet does exactly that.
Java Code:Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connection = DriverManager.getConnection("jdbc:odbc:dd","",""); // Create a result set Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM test"); // 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 { String columnName = rsmd.getColumnName(i); // Get the name of the column's table name String tableName = rsmd.getTableName(i); System.out.println("columnName "+columnName);
Similar Threads
-
Using Columns With JTextField
By The Evil Genius in forum AWT / SwingReplies: 1Last Post: 03-17-2008, 01:01 AM -
Problems updating blob columns on Oracle 9
By ljustiniano in forum JDBCReplies: 0Last Post: 08-14-2007, 06:17 PM -
Displaying different columns with database query
By jennybgh in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 08-02-2007, 05:04 PM -
Problems with JSF (columns)
By Peter in forum JavaServer Faces (JSF)Replies: 2Last Post: 07-04-2007, 06:43 AM -
sort columns in jtable
By Alan in forum AWT / SwingReplies: 2Last Post: 05-14-2007, 05:18 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks