Forum Stats

  • 3,770,003 Users
  • 2,253,045 Discussions
  • 7,875,265 Comments

Discussions

Oracle DB connection from eclipse web application in jsp using apache server.xml file

Sunny86
Sunny86 Member Posts: 255 Blue Ribbon

Hello

I am a newbie in java and trying to figure out a oracle data base connection from eclipse ide and tomcat server. Placed the code in server.xml like below.

<span class="tag" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;"><Resource</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">name</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"jdbc/SalesDB"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">global</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"jdbc/SalesDB"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">auth</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"Container"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">type</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"javax.sql.DataSource"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">driverClassName</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"oracle.jdbc.OracleDriver"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">url</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"jdbc:oracle:thin:@localhost:1521:xe"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">username</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"sales"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">password</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"sales123"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">  </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">maxActive</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"100"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">maxIdle</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"20"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">minIdle</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"5"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">maxWait</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"10000"</span><span class="tag" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">/></span>

THen placed the details in

context.xml like below

<span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="tag" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;"><ResourceLink</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">name</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"jdbc/MyLocalDB"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">global</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"jdbc/SalesDB"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">auth</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"Container"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="atn" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #e64320;">type</span><span class="pun" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;">=</span><span class="atv" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #0f74bd;">"javax.sql.DataSource"</span><span class="pln" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #303336;"> </span><span class="tag" style="font-style: inherit; font-weight: inherit; font-size: inherit; font-family: inherit; color: #7d2727;">/></span>

Now i would like to find the path which can be used in jsp page. enter image description here

ds=(DataSource) ctx.lookup("java:/jdbc/MyLocalDB");

Answers

This discussion has been closed.