• JDBC获取表注释


    代码部分:

     1 @Before
     2     public void loadDriver() {
     3         try {
     4             Class.forName("oracle.jdbc.driver.OracleDriver");
     5         } catch (ClassNotFoundException e) {
     6             // TODO Auto-generated catch block
     7             e.printStackTrace();
     8         }
     9     }
    10 
    11     @Test
    12     public void testConn() {
    13         String url = "jdbc:oracle:thin:@10.0.0.7:1521:ddgx10g"; // orcl为数据库的SID
    14         String user = "njzjdbc";
    15         String password = "123";
    16 
    17         Properties props = new Properties();
    18         props.put("remarksReporting", "true");
    19         props.put("user", user);
    20         props.put("password", password);
    21 
    22         DatabaseMetaData dbmd = null;
    23         ResultSet rs = null;
    24         Connection dbConn = null;
    25         try {
    26             dbConn = DriverManager.getConnection(url, props);
    27         
    28             dbmd = dbConn.getMetaData();
    29         
    30             rs = dbmd.getColumns(dbConn.getCatalog(), "NJZJDBC", "O_NJZJWEB_AJQY_ALL", "%");
    31         
    32             while (rs.next()) {
    33                 String columnName = rs.getString("COLUMN_NAME");
    34                 String columnRemarks = rs.getString("REMARKS");
    35                 System.out.println("columnName:" + columnName
    36                         + ",columnRemarks:" + columnRemarks);
    37             }
    38         } catch (SQLException e) {
    39             // TODO Auto-generated catch block
    40             e.printStackTrace();
    41         }finally{
    42             JdbcUtil.close(rs, null, conn);
    43         }

    运行结果:

  • 相关阅读:
    JAVA DBUTils和连接池
    JAVA jsp技术
    java cookie学习
    grub引导
    更改网卡顺序及名称
    ambari 警告信息
    radhat7.2 救援模式
    radhat7.2 系统引导修复
    sehll编程入门
    HBase安装部署
  • 原文地址:https://www.cnblogs.com/lucky2u/p/3680467.html
Copyright © 2020-2023  润新知