Accessing database connect information in ADF

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. 

 

Comments:

Post a Comment:
Comments are closed for this entry.
About

The Oracle JDeveloper forum ranks in the Top 5 of the most active forums on the Oracle Technology Network (OTN).



The OTN Harvest blog is a summary of selected topics posted on the OTN Oracle JDeveloper forum.



It is an effort to turn knowledge exchange into an interesting read for developers who enjoy little nuggets of wisdom





Frank Nimphius

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today