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 ));}