您的位置:首页 > 编程语言 > Java开发

Java 通过JDBC查询数据库表结构(字段名称,类型,长度等)

2012-11-20 17:48 736 查看
通过ResultSetMetaData 对象获取 数据库表结构(字段名称,类型,长度等)

package java.sql;

/**

* An object that can be used to get information about the types

* and properties of the columns in a <code>ResultSet</code> object.

* The following code fragment creates the <code>ResultSet</code> object rs,

* creates the <code>ResultSetMetaData</code> object rsmd, and uses rsmd

* to find out how many columns rs has and whether the first column in rs

* can be used in a <code>WHERE</code> clause.

* <PRE>

*

* ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2");

* ResultSetMetaData rsmd = rs.getMetaData();

* int numberOfColumns = rsmd.getColumnCount();

* boolean b = rsmd.isSearchable(1);

*

* </PRE>

*/

publicinterface ResultSetMetaData extends Wrapper

http://blog.csdn.net/luju5/article/details/8204710
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐