擷取AM指定的JDBC Datasource

來源:互聯網
上載者:User

 

概述
本文主要描述如如何在ADF中可以擷取AM中指定的JDBC Datasource。

實現
1、建立ADF應用,為Model添加資料庫連接

 

2、建立Application Module,在Configurations中選擇Local,修改“Connection Type”為JDBC Datasource方式

3、AM的實作類別中添加如下代碼:

import javax.naming.Context;<br />import javax.naming.InitialContext;</p><p>import javax.naming.NamingException;<br />import oracle.jbo.client.Configuration;<br />import weblogic.jdbc.common.internal.RmiDataSource;<br />……<br /> public void getCurrentAMDatasource() {<br /> Context ctx;<br /> try {<br /> ctx = new InitialContext();<br /> RmiDataSource ds =<br /> (RmiDataSource)ctx.lookup((String)this.getSession().getEnvironment().get(Configuration.DB_CONNECTION_PROPERTY));<br /> System.out.println(ds.getPoolName());<br /> System.out.println(ds.getJNDINames().length);<br /> System.out.println(ds.getJNDINames()[0]);<br /> } catch (NamingException e) {<br /> e.printStackTrace();<br /> }<br /> } 

 

4、將該方法發布到Client Interface

5、在ViewController項目中建立新頁面,拖動按鈕到該頁面,將按鈕的ActionListener綁定到發布成為Client Interface的方法

6、儲存並運行應用,在控制台列印出的結果如下:

[09:34:31 AM] Application Deployed Successfully.<br />[09:34:31 AM] The following URL context root(s) were defined and can be used as a starting point to test your application:<br />[09:34:31 AM] http://10.213.246.232:7101/howtogetdatasource-ViewController-context-root<br />[09:34:31 AM] Elapsed time for deployment: 26 seconds<br />Run startup time: 26203 ms.[09:34:31 AM] ---- Deployment finished. ----</p><p>[Application howtogetdatasource deployed to Server Instance IntegratedWebLogicServer]</p><p>Target URL -- http://127.0.0.1:7101/howtogetdatasource-ViewController-context-root/faces/main.jspx<br />howto<br />1<br />jdbc/howtoDS 

本文轉自Oracle Seeker:http://oracleseeker.com/2009/12/08/adf_am_jdbc_datasource_jndi/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.