Obtain the JDBC datasource specified by AM.

Source: Internet
Author: User

 

Overview
This document describes how to obtain the JDBC datasource specified in AM in the ADF.

Implementation
1. Create an ADF application and add a database connection for the model.

 

2. Create an application module, select local in deployments, and change "connection type" to the JDBC datasource mode.

3. Add the following code to the implementation class of 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. Publish the method to the client interface

5. Create a page in the viewcontroller project, drag the button to the page, and bind the actionlistener of the button to the method for publishing the interface to the client.

6. Save and run the application. The result displayed on the console is as follows:

[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.133: 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 

This article is transferred from Oracle Seeker: http://oracleseeker.com/2009/12/08/adf_am_jdbc_datasource_jndi/

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.