dcsimg
how do i kno the name and type of the table columns
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abhisek_Sinha
Posted On:   Monday, July 15, 2002 06:10 AM

I want to know the name and type of the table columns.
i can do "describe tableName" on sql prompt.
but what is the jdbc function that returns the same information as the "describe ...".
i want to have that result in ResultSet.
thanks in advance

Re: how do i kno the name and type of the table columns

Posted By:   Stephen_McConnell  
Posted On:   Monday, July 15, 2002 06:24 AM

Look at the java.sql.ResultSetMetaData interface.


Stephen McConnell

Re: how do i kno the name and type of the table columns

Posted By:   Simone_Re  
Posted On:   Monday, July 15, 2002 06:23 AM

Try the java.sql.ResultSetMetaData object.



ResultSet rs = st.executeQuery("SELECT * FROM table1");
ResultSetMetaData rsmd = rs.getMetaData();
for(int i=1;i<=rsmd.getColumnCount();i++) {
System.out.println(rsmd.getColumnName(i));
System.out.println(rsmd.getColumnType(i));
}

Look at the API for more information.
About | Sitemap | Contact