Obtain field comments from Oracle using databasemetadata

Source: Internet
Author: User

 

I have been wondering about the problem of getting comments from the databasemetadata interface. I happened to check this article online, but I don't know if it is correct. I need to verify it later.

When extending the ibator plug-in today, when generating comments for each field in the model, you want to obtain comments for each field from the Oracle database as a comment. The JDBC support code is as follows:

Resultset rs = (Java. SQL. databasemetadata) databasemetadata. getcolumns (localcatalog, localschema, localtablename, null );

While (Rs. Next ()){
Rs. getstring ("Remarks "));

.............................

Java. SQL. databasemetadata. the getcolumns method can be clearly seen from the annotations. It can obtain the diversified information of the database, including the comments of tables and fields. however, it is null when I get it. after Google spent half a day, it was found that Oracle had to set whether to obtain comments by using a parameter when connecting JDBC to obtain the connection. the details are as follows:

Properties props = newproperties ();

Props. Put ("remarksreporting", "true ");
Class. forname ("oracle. JDBC. Driver. oracledriver ");

Dbconn = drivermanager. getconnection (URL, props );
Databasemetadata dbmd = dbconn. getmetadata ();

Rs = dbmd. getcolumns (null, "ops $ aimsadm", "aircrafts", "Code ");

If (Rs. Next () {system. Out. println ("Remarks:" + Rs. GetObject (12 ));}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.