File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Databases
»
JDBC
Author
JDBC resourceRef wrong on Tomcat 6
Steve Nelligan
Greenhorn
Joined: Nov 09, 2010
Posts: 10
posted
Nov 10, 2010 14:34:27
0
When I list the environment Object the following is the list of objects I get.
I believe that all of them should be org.apache.tomcat.dbcp.dbcp.BasicDataSource
Each was declared the same except the fsSql uses a Microsoft Driver and jTDS using a jtds driver for MS-SQL.
I added "factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" to the context file, but this did not help.
Any ideas why the SQL connections are being created differently?
This is list of envctr Objects fsSql: org.apache.naming.ResourceRef fsAiM: org.apache.tomcat.dbcp.dbcp.BasicDataSource jTDS: org.apache.naming.ResourceRef
Thanks in advance.
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
I like...
posted
Nov 11, 2010 02:02:05
0
I believe that all of them should be org.apache.tomcat.dbcp.dbcp.BasicDataSource
Why do you believe this? I would guess jTDS doesn't use DBCP.
JavaRanch FAQ
HowToAskQuestionsOnJavaRanch
Steve Nelligan
Greenhorn
Joined: Nov 09, 2010
Posts: 10
posted
Nov 11, 2010 05:36:42
0
I am trying to setup
Tomcat
to use JNDI for dataConnections.
I have Oracle working, but can not get SQL working. What I was looking for was differences between the Oracle and SQL connections.
I can't figure out why Oracle would work, but not SQL.
This is the error I am getting on the screen when trying to connect to a SQL Server:
type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: An exception occurred processing JSP page /SqlTest2.jsp at line 15 12: Context ctx = new InitialContext(); 13: Context envctx = (Context) ctx.lookup("java:comp/env"); 14: DataSource ds = (DataSource) envctx.lookup("jdbc/fsSql"); 15: Connection conn=ds.getConnection(); 16: Statement st=conn.createStatement(); 17: String sql="SELECT @@SERVERNAME"; 18: ResultSet rs=st.executeQuery(sql); Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419) 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 java.lang.NullPointerException org.apache.jsp.SqlTest2_jsp._jspService(SqlTest2_jsp.java:71) 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.
Error Log:
Nov 11, 2010 6:32:58 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet jsp threw exception java.lang.NullPointerException at org.apache.jsp.SqlTest2_jsp._jspService(SqlTest2_jsp.java:71) 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)
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: JDBC resourceRef wrong on Tomcat 6
Similar Threads
Hibernate to connect to MS SQL
Update query
Class.forName in depth
JDBC-ODBC
Using a Datasource to connect to database
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter