Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Oracle9ias OCJ4 Data Sources

Posted on 2003-03-27
8
Medium Priority
?
2,219 Views
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.

oscarlg.
0
Comment
Question by:oscarlg
  • 4
  • 4
8 Comments
 
LVL 9

Expert Comment

by:vzilka
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:
     <data-source
          class="com.evermind.sql.DriverManagerDataSource"
          name="OracleDS"
          location="jdbc/OracleCoreDS"
          xa-location="jdbc/xa/OracleXADS"
          ejb-location="jdbc/OracleDS"
          connection-driver="oracle.jdbc.driver.OracleDriver"
          username="hr"
          password="hr"
          url="jdbc:oracle:thin:@localhost:1521:ORA9i"
          inactivity-timeout="30"
     />
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.
0
 

Author Comment

by:oscarlg
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.
0
 
LVL 9

Expert Comment

by:vzilka
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.
0
The Firewall Audit Checklist

Preparing for a firewall audit today is almost impossible.
AlgoSec, together with some of the largest global organizations and auditors, has created a checklist to follow when preparing for your firewall audit. Simplify risk mitigation while staying compliant all of the time!

 

Author Comment

by:oscarlg
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).
0
 
LVL 9

Expert Comment

by:vzilka
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.
0
 

Author Comment

by:oscarlg
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.

:)
0
 
LVL 9

Accepted Solution

by:
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:
<welcome-file-list>
          <welcome-file>/query.html</welcome-file>
</welcome-file-list>
and a servlet-mapping tag:
<servlet>
  <servlet-name>DeptListServlet</servlet-name>
  <servlet-class>deptdemo.DeptListServlet</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>DeptListServlet</servlet-name>
  <url-pattern>/deptListServlet</url-pattern>
</servlet-mapping>

You put the application.xml file inside the META-INF directory. This is a basic example:
<application>
  <display-name>DeptAppMP</display-name>
  <module>
    <ejb>EJB</ejb>
  </module>
  <module>
    <web>
      <web-uri>WEB</web-uri>
      <context-root>/DeptAppMP</context-root>
    </web>
  </module>
</application>

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.


0
 

Author Comment

by:oscarlg
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.....
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

Convert websphere application server default chained Certificates from 1024 to 2048 keysize or higher size and also you can change signatureAlgorithm . Please make sure Websphere Application Server fixpack 7.0.0.23 or Above. The following steps a…
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 …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

578 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