Can anyone provide a step-by-step 'hello world' procedure for setting up
data-sources.xml properly and calling the resource from within a servlet?
Alternatively, can someone review my setup and comment on what might be
wrong?
The section of my data-sources.xml looks like this:
<data-source
class="com.evermind.sql.DriverManagerDataSource"
name="jdbc/d123DS"
location="jdbc/d123DS"
xa-location="jdbc/xa/d123XADS"
ejb-location="jdbc/d123DS"
connection-driver="oracle.jdbc.driver.OracleDriver"
username="username"
password="password"
url="jdbc:oracle:thin:my.oracle.host:@dev2:1521:D123DEV"
inactivity-timeout="30"
/>
I'm attempting to create a connection within my servlet. Snippets of
the relevant code:
public class DSTest extends HttpServlet
{
InitialContext ctx;
DataSource ds;
...
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
try {
ctx=new InitialContext();
ds = (DataSource) ctx.lookup("java:comp/env/jdbc/d123DS");
con = ds.getConnection();
...
}
...
catch (NamingException e) { System.out.println(e); }
}
It is catching the NamingException, telling me:
javax.naming.NamingException: Error instantiating web-app JNDI-context: No
location specified for resource-ref d123DS
So I went and added to my application's web.xml, since this isn't under the
default orion application:
<context-param>
<param-name>d123DS</param-name>
<param-value>jdbc/d123DS</param-value>
</context-param>
<resource-ref>
<description>Test Data Source</description>
<res-ref-name>d123DS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
And it still catches the same exception.
Am I missing something simple? I'll gladly write up a tutorial for this for
orionsupport.com if I can get this working.
My environment: jdk 1.3, orion 1.4.0
Any help would be wonderful.
--
David S. Kenzik
[EMAIL PROTECTED] - http://kenzik.com
Original Music - http://mp3.com/text