Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes Trying to connect to SQL-2005 with JDBC and JNDI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Trying to connect to SQL-2005 with JDBC and JNDI " Watch "Trying to connect to SQL-2005 with JDBC and JNDI " New topic
Author

Trying to connect to SQL-2005 with JDBC and JNDI

Steve Nelligan
Greenhorn

Joined: Nov 09, 2010
Posts: 10

I finally got the Oracle database connections working with JNDI.

I still can not get connected to SQL-2005 with JNDI

I have tried sqljdbc4.jar, sqljdbc4-2.0.jar, and jtds.jar but none are able to connect to SQL-2005.

Has anyone gotten connected to SQL-2005 using JNDI and Tomcat 6?

If so, could you describe:
1. which driver you used (which jar)
2. the driver class
3. the driver url
4. context.xml resource block
5. web.xml resource-ref block.

The following is the exception I am getting:
Nov 10, 2010 9:45:07 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
javax.naming.NamingException: Cannot create resource instance
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.jsp.jtdsTest2_jsp._jspService(jtdsTest2_jsp.java:70)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)

Any information would help

Thanks in advance
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

All of the drivers you mention work fine.

Can you post the stack trace that will be occurring when Tomcat tried to create your DataSource (rather than the one when your code fails to look it up)? The reason this is failing is almost certainly detailed in the log.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Steve Nelligan
Greenhorn

Joined: Nov 09, 2010
Posts: 10

I have can not attach the log files, it always blocks the file, so I have pasted them below....

Neither show any errors.

The error only shows up when running the application


To get everything working, I have a context.xml files in:
tomcat\conf
tomcat\webapps\birt\META-INF
tomcat\webapps\birt\webcontent\META-INF

and web.xml in \tomcat\webapps\birt\WEB-INF



catalina


localhost
Steve Nelligan
Greenhorn

Joined: Nov 09, 2010
Posts: 10

This is the full HTTP: message on the browser:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.naming.NamingException: Cannot create resource instance
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

javax.servlet.ServletException: javax.naming.NamingException: Cannot create resource instance
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.SqlTest2_jsp._jspService(SqlTest2_jsp.java:98)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

javax.naming.NamingException: Cannot create resource instance
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
org.apache.naming.NamingContext.lookup(NamingContext.java:793)
org.apache.naming.NamingContext.lookup(NamingContext.java:140)
org.apache.naming.NamingContext.lookup(NamingContext.java:781)
org.apache.naming.NamingContext.lookup(NamingContext.java:153)
org.apache.jsp.SqlTest2_jsp._jspService(SqlTest2_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.26 logs.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Are you connecting via BIRT? Or directly from your web application? Can you show us the context.xml you are using (you probably want to remove the ones you are not) and the code you use to look up the DataSource?

Steve Nelligan
Greenhorn

Joined: Nov 09, 2010
Posts: 10

Long term, I want to use Birt, but since I had problems getting it to work, I started with a JSP Page to use the JDNI, When I get this working, I would then start fighting with Birt.

the JSP Page:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trying to connect to SQL-2005 with JDBC and JNDI
 
Similar Threads
NewBee trying to get JNDI working with Tomcat 6
Servlet.service() for servlet jsp threw exception
Update -- Trying to get JNDI working with Tomcat 6
help in my first DBCP
JDBC resourceRef wrong on Tomcat 6