• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

DataBase Connection via DataSource using Oracle 10g and tomcat 6

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can any body let me know that, is there any need of below code in web.xml file, for connecting oracle 10g database via DataSource using tomcat 6.



<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/myoracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>


or what other configurations are req. to connect with database oracle 10g via DataSource.

Regards
Atharva.
 
Ranch Hand
Posts: 56
Netbeans IDE Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This will be part of Web.xml, this will refer to the Resource name which is defined in the server.xml, so the referrence must be added in the web.xml and there must be a definiton for the resource in the server.xml

I think you are also able to add this in the context.xml. so you might want to check the below link to know in detail about this.

http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html

In general the way to define your datasource will depend on the type of project and the type of frame-work, in your case i am guessing it is required in the web.xml

 
Saloon Keeper
Posts: 28654
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To qualify Sachin's response: define the database connection pool in the "context.xml" file if this pool will only be used for a single webapp (the webapp that the Context definition defines). Define it in server.xml only if the same pool is common to more than one webapp.

I said "context.xml" in quotes, because the name of that file can vary depending on where it's located, but that's not something specific only to database connections.
 
Atharva Gupta
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

Actually what i have done,

1. i have added ojdbc14.jar in tomcat 6 lib directory.
2. i have added entry in context.xml, code is below.

<Resource name="jdbc/myoracle" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:orcl"
username="dbunit" password="dbunit" maxActive="20" maxIdle="10"
maxWait="-1"/>

i have not done any entry in web.xml, but i have seen entry in web.xml in so many documents.

but ibnspite of adding entry in web.xml, i am able to connect to the database using the datasource config, in context.xml
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic