Oracle9ias OCJ4 Data Sources

Posted on 2003-03-27
Medium Priority
Last Modified: 2007-12-19
I've developed a web project using struts on a Tomcat 3.3 server connected to an Oracle 8i DB.
In the Tomcat environment, the connection to the DB is made using the usual DriverManager.getConnection / thin driver and it works fine.

The production server is OiAs (OCJ4) and I want to setup a DataSource to use the pooled jdbc connections. After setting up the data-sources.xml, I guess that database connection related classes must be re-coded, can anybody explain me the steps that I must follow until the final EAR is generated, knowing that struts is involved?

Best regards and thanks in advance.

Question by:oscarlg
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4

Expert Comment

ID: 8233509
Hi Oscarlg,

1. The easiest thing to do is to configure the data-sources.xml file inside the OC4J_HOME\config directory.
You create a data source to your server through it. It will look similar to this:
Depending on your user name and SID name.

2. Then, your get the data-source through a lookup operation on the InitialContext object.
Try this line:
InitialContext ic = new InitialContext();
Since you are using the data-source through a servlet, you don't need to specify parameters for the InitialContext object.
Then do this:
DataSource ds = (javax.sql.DataSource)ic.lookup("jdbc/OracleDS");
(Assuming this is the name of your DataSource).

3. To get a connection to the database use the following line:
Connection conn = ds.getConnection();

This should do it.

Author Comment

ID: 8237254
Thanks for the copy-paste vzilka, but I also have the OAS how-to documentation ;)

Sorry for the joke. I guess that I've hadn't explained very well because my poor english... I've already done the connection and the changes in the datasource.xml. My problem is the generation of the EAR file and the test of the connection in the deployed environment.

I know the files that must be created to performa a correct EAR deployment (application.xml, orion.web.xml) but not what information i must include to publish the application in a given directory.to test the connection.

I hope you can help me.

Expert Comment

ID: 8237306
First of all, sorry about that. I thought this is what you were after.
About the deployment - You deploy your ear file in OC4J by using server.xml and http-web-site.xml. If you want information about these files - I'd be happy to show you how.
Testing the DB connection can only be done by your application. Why not write a small JSP that access the DataSource, deploy it in the default-web-app directory, and see if the connection works? Then you can go ahead with deploying the EAR file to OC4J.

BTW - if you have JDeveloper (free download) you can use it to deploy to OC4J, including all XML files and all DB connections.
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.


Author Comment

ID: 8251706
The problem with jdev is the following:
It allows you to put the blank xml config files in the right places of your deployment directories but doesn't has any user-friendly tool to prepare the deployment with ears or wars (I don't have direct access to the production server).

Expert Comment

ID: 8251726
Which JDeveloper version are you using?
903 (Which you can download from otn.oracle.com) allows you to select the XML file, right-click it in the project explorer, and select settings. This allows you to set properties in the XML file.

Author Comment

ID: 8268813
I'm using the same version JDev 9.0.3.
Perhaps my problem is that i don't know how to use the tools... :(

I'll try another extended explanation. I've my app working in a pre-production server but using the "directory deployment" that is: The jsp pages are in [oias]\home\default-web-app\myapp\, the jar containing the classes is the [oias]\home\default-web-app\myapp\web-inf\lib,  and i've redirected the default web app (changing the default_web_app in application.xml) to it.

Now, i want to generate the ear and war files to allow the production server administrator to perform a more "professional" deployment using the administration tools of O9iAS. What is the minimal configuration that I need to add to my META-INF\application.xml and the WEB-INF\orion-web.xml to configure the application name and the deployment directory (supposing that both of them are called myapp).

Hope I've explained.

Thanks for the effort.


Accepted Solution

vzilka earned 750 total points
ID: 8283116
You don't need to build your orion-web.xml file by hand - this is done by Oracle9iAS automatically.
You do need a web.xml file (in the WEB-INF directory) which will contain the welcome-file-list tag:
and a servlet-mapping tag:

You put the application.xml file inside the META-INF directory. This is a basic example:

When you deploy this application in Oracle9iAS, the mapping of the URL will be displayed automatically in the OEM, so it should be very easy for your deployer to use.


Author Comment

ID: 8365241
I've discovered that the problem with the deployment was not the xml configuration files but the inclusion of some jars with the ear files.

Thanks for your effort.

Best regards.....

Featured Post

The Ideal Solution for Multi-Display Applications

Check out ATEN’s VS1912 12-Port DP Video Wall Media Player at InfoComm 2017. Kerri describes how easy it is to design creative video walls in asymmetric layouts and schedule detailed playlists ahead of time with its advanced scheduling feature.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question