X

The blog for hints & tips about Oracle Application Development Framework and Mobile Application Framework

  • ADFm
    August 2, 2011

Accessing database connect information in ADF

Frank Nimphius
Master Principal Product Manager

To get the database connect information of an ADF BC model in ADF, expose the following code in a public method on the ApplicationModule Impl
class

public String getDatabaseInformation(){
  DBTransaction dbTransaction = (DBTransaction) this.getTransaction();
  PreparedStatement prepStatement =
              dbTransaction.createPreparedStatement("select * from dual", 0);    try {
    String dbSchema =
                  prepStatement.getConnection().getMetaData().getUserName();
    String connectURL =
                  prepStatement.getConnection().getMetaData().getURL();
    //returns schema_name@host:port:sid
    return dbSchema + connectURL.substring(connectURL.indexOf("@")-1);             
} catch (SQLException e) {
      e.printStackTrace();
   }
    return null;
}
 

Expose this method on the AM client interface if you need this to be accessible from the ADF client, for example a method binding in a PageDef file, or a managed bean.
 

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.