?
Solved

How to Connect Oracle 9i by using Struts

Posted on 2003-10-28
12
Medium Priority
?
509 Views
Last Modified: 2008-02-01
i am using Tomcat 4.1.27 as my web server and i have set classes12.jar to my CLASSPATH, and put the jar file in the library of tomcat, but i can't still get a connection to Oracle 9i

Help me plz..........................

i want to know the following answers
1. How to configure the environment in Tomcat and Window xp when i make
    connection to Oracle 9i by using struts
2. What is the coding to make the connection( giving a example code would be
    better)

Additional Question (option to answer)
3. Where can find sample code of struts except Oracle and Apache Website

P.S.
i am using eclipse as my tools to programming
Thank You for your help.........................
0
Comment
Question by:ronancheung
[X]
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
  • 3
  • 3
12 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 272 total points
ID: 9634988
>>but i can't still get a connection to Oracle 9i

Meaning what exactly? Where have you put the jar in Tomcat?

Here's an example datasource config in struts-config.xml:

<struts-config>


  <!-- ========== Data Source Configuration =============================== -->
<!--
 <data-sources>
   <data-source>
     <set-property property="autoCommit"
                      value="false"/>
     <set-property property="description"
                      value="Example Data Source Configuration"/>
     <set-property property="driverClass"
                      value="org.postgresql.Driver"/>
     <set-property property="maxCount"
                      value="4"/>
     <set-property property="minCount"
                      value="2"/>
     <set-property property="password"
                      value="mypassword"/>
     <set-property property="url"
                      value="jdbc:postgresql://localhost/mydatabase"/>
     <set-property property="user"
                      value="myusername"/>
   </data-source>
 </data-sources>
...

</struts-config>
0
 
LVL 2

Assisted Solution

by:f_98
f_98 earned 268 total points
ID: 9635100
1) put classes12 at the WEB-INF/lib directory of your app

then at the struts-config.xml set up a datasource (like the one CEHJ posted)

(i usually use commons for pooling so i have that commons-dbcp at the lib dir)

<data-sources>
   <data-source type="org.apache.commons.dbcp.BasicDataSource" >
    <set-property
      property="driverClassName"
      value="oracle.jdbc.OracleDriver" />
    <set-property
      property="url"
      value="jdbc:oracle:thin:@192.168.0.30:11001:testDB" />
    <set-property
      property="maxActive"
      value="10" />
    <set-property
      property="maxWait"
      value="5000" />
    <set-property
      property="defaultAutoCommit"
      value="false" />
    <set-property
      property="defaultReadOnly"
      value="false" />
    <set-property
      property="validationQuery"
      value="SELECT SYSDATE FROM DUAL" />
    <set-property
      property="username"
      value="testDB" />
    <set-property
      property="password"
      value="testDB" />
   </data-source>
 </data-sources>

2) to get a connection  (in your Action)
import javax.sql.DataSource

DataSource dataSource = getDataSource(request);
Connection conn = dataSource.getConnection();

3) i found lots of good java resource from a certain file sharing network.
0
 

Author Comment

by:ronancheung
ID: 9635276
i use a library like common-dbcp 1.1, but it throws a exception of "no suitable driver", but i have put the driver (classes12.jar) in  WEB-INF/lib folder. but i don't know why?

Help me plz.......................
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 86

Expert Comment

by:CEHJ
ID: 9635291
Have you restarted the container since?
0
 

Author Comment

by:ronancheung
ID: 9638016
yes i have retarted the container
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9640759
Make sure that particular driver class *is in* the jar you put into WEB-INF/lib
0
 

Author Comment

by:ronancheung
ID: 9647112
Thank you for your reply
yes, i have done that
but it still throw a exception of "No suitable Driver"
Help me plz......................
i really want to do that
0
 
LVL 2

Expert Comment

by:f_98
ID: 9648926
try removing all other classes.12 jar in your classpath
like in common/lib, etc.

there's this nasty little "problem/feature" in tomcat about jars being loaded by different classloaders.
0
 
LVL 2

Expert Comment

by:f_98
ID: 9648936
also try removing other instances of dbcp jar in the classpath , just put it in web-inf/lib
0
 

Author Comment

by:ronancheung
ID: 9661573
Now there are no more exception thrown
but i don't know that it really have connected Oralce
Anyone have some sample code
Thank you for all reply!!!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month11 days, 7 hours left to enroll

752 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