DatabaseMetaData 获取 Oralce 注释内容

本文深入探讨了为什么在软件开发领域中,大多数程序员难以晋升为架构师的原因,从个人技能、团队合作到项目管理等方面进行解析。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

setRemarksReporting

setRemarksReporting

public void setRemarksReporting(boolean reportRemarks)
Turns on or off the reporting of the REMARKS columns by the getTables and getColumns calls of the DatabaseMetaData interface.
The DatabaseMetaData calls getTables and getColumns are extremely slow if the REMARKS column has to be reported as this necessitates an expensive outer join so by default the JDBC driver does not report the REMARKS columns.

You can turn the reporting of REMARKS on by passing a true argument to this method. You turn it back off by passing a false argument.

Example where conn is your connection object:
((OracleConnection)conn).setRemarksReporting(true);

You can also control the reporting of REMARKS by passing a property named remarksReporting as true to the DriverManager.getConnection call.

Parameters:
reportRemarks - true if you want to turn on the reporting of the REMARKS columns and false otherwise.
See Also:
getRemarksReporting
API:

oracle.jdbc 

Interface OracleConnection

转载于:https://my.oschina.net/i33/blog/170523

要使用 `ResultSet` 获取Oracle数据库字段的注释,可以使用以下步骤: 1. 使用 `DatabaseMetaData` 获取表的元数据信息。你可以通过 `Connection` 对象的 `getMetaData` 方法获取 `DatabaseMetaData` 对象。 ```java Connection connection = DriverManager.getConnection(url, username, password); DatabaseMetaData metaData = connection.getMetaData(); ``` 2. 使用 `DatabaseMetaData` 对象的 `getColumns` 方法获取表的列信息。你需要提供表的模式(可选)和表名作为参数。 ```java ResultSet columns = metaData.getColumns(null, schema, table, null); ``` 在上述代码中,`schema` 是模式名称,`table` 是表名称。通过调用 `getColumns` 方法,将返回一个 `ResultSet` 对象,其中包含了表的列信息。 3. 遍历 `ResultSet` 对象,获取每一列的注释。使用 `ResultSet` 对象的 `getString` 方法,并传入 `"REMARKS"` 作为参数,可以获取列的注释信息。 ```java while (columns.next()) { String columnName = columns.getString("COLUMN_NAME"); String columnRemark = columns.getString("REMARKS"); System.out.println("Column: " + columnName + ", Remark: " + columnRemark); } ``` 在上述代码中,通过调用 `getString("COLUMN_NAME")` 和 `getString("REMARKS")` 方法,分别获取列名和注释信息。 请注意,上述代码是基于使用 JDBC 连接到 Oracle 数据库的情况。确保你已经加载了适当的数据库驱动程序,并提供正确的连接信息(URL、用户名和密码)。 此外,需要注意的是,注释信息可能不是在每个数据库中都有,具体取决于数据库的设置和注释的使用情况。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值