• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DataBase Connection via DataSource using Oracle 10g and tomcat 6

 
Atharva Gupta
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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.
 
Sachin Pachari
Ranch Hand
Posts: 56
Eclipse IDE Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • 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

 
Tim Holloway
Saloon Keeper
Posts: 18302
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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="jdbcracle:thin:@localhost:1521rcl"
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic