欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jdbc获取表中列名

程序员文章站 2022-04-20 08:29:14
...
   1. pment = conn.prepareStatement("select * from A0001 where 1 = 2");  
2. rs = pment.executeQuery();
3. ResultSetMetaData metaData = rs.getMetaData();
4. int colum = metaData.getColumnCount();
5. for (int i = 1; i <= colum; i++)
6. {
7. String typeStr = ""; //类型
8. //获取列名
9. String columName = metaData.getColumnName(i);
10. //获取每一列的数据类型
11. int type = metaData.getColumnType(i);
12. //判断
13. if(Types.INTEGER == type)
14. {
15. typeStr = "Integer";
16. }
17. else if(Types.VARCHAR == type)
18. {
19. typeStr = "String";
20. }
21. }
相关标签: JDBC