Tomcat JDBC setup: DataSource invalid: "java.lang.NullPointerException"

C

cwang66

Hi,

I am trying to configure JDBC connecting to MS SQL 2000 in Tomcat
5.5.9. I have tried using JDBC drivers from both Microsoft and JTDS. I
copied JDBC jar files to [Tomcat_home]shared\lib" in both cases.
However, I am getting the following error message from both cases( I am
using JSTL in my JSP page.):

javax.servlet.jsp.JspException: Unable to get connection, DataSource
invalid: "java.lang.NullPointerException"
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:276)
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:159)
org.apache.taglibs.standard.tag.el.sql.QueryTag.doStartTag(QueryTag.java:85)
org.apache.jsp.userReport_jsp._jspx_meth_sql_query_0(org.apache.jsp.userReport_jsp:307)
org.apache.jsp.userReport_jsp._jspx_meth_c_when_0(org.apache.jsp.userReport_jsp:241)
org.apache.jsp.userReport_jsp._jspx_meth_c_choose_0(org.apache.jsp.userReport_jsp:203)
org.apache.jsp.userReport_jsp._jspService(org.apache.jsp.userReport_jsp:120)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Below is my web.xml configuration when using JTDS driver:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.3.dtd">
<web-app>
<context-param>

<param-name>
net.sourceforge.jtds.jdbcx.JtdsDataSource
</param-name>
<param-value>
jdbc:jtds:sqlserver://127.0.0.1:1433/testdb;user=xxx;password=xxx
</param-value>

</context-param>


</web-app>


Below is my web.xml configuration when using MS driver:

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.3.dtd">
<web-app>
<context-param>


<context-param>
<param-name>com.microsoft.jdbc.sqlserver.SQLServerDriver</param-name>

<param-alue>jdbc:microsoft:sqlserver://localhost:1433;User=xxx;Password=xxx;DatabaseName=testdb</param-value>

</context-param>

</context-param>


</web-app>



Any help is appreciated.
 
M

Manish Pandit

Try putting the jar files in your webapp's WEB-INF/lib folder as well.

I had this problem too, and ended up using Apache DBCP instead of
having a JNDI datasource via tomcat.

-cheers,
Manish
 
C

cwang66

The hosts file is setup by default to have the localhost setup in it. I
forgot to mention that I did get JDBC to work with mySQL (so I am
guessing maybe it's naming convention I use for M$ SQL is wrong.). I
am getting the same error message in another machine with the same
setup.

I will look into using DBCP as another solution. The frustrating part
of this small coding project is that the error message is really not
very meaningful for debugging purpose. Is there any way to configure
JSTL to spit out more verbose error message?

Thanks,
 
R

Roedy Green

I will look into using DBCP as another solution. The frustrating part
of this small coding project is that the error message is really not
very meaningful for debugging purpose. Is there any way to configure
JSTL to spit out more verbose error message?

I notice a higher and higher proportion of questions are about
configuring. Nobody can help unless they are familiar with that
particular program.

What we need is something akin to
http://mindprod.com/jgloss/runerrormessages.html

Where every time you make a mistake and figure out what you did wrong,
you log the error message and the cause. That would give others who
come after you, and yourself later encountering a similar problem a
hint.

The catch is I am not the one to do this. I am not using all these
different tools. Further I find the syntax of these configuration
files nauseating. And I go apoplectic reading the worse than useless
documentation on how to set them up. I want nothing to do with them.

Perhaps some masochist needs to write a book called
"How to configure"

a cookbook about configuring various popular tools, and the various
tricks for getting your files to work even when the manuals read like
Greek.

It might even come with a program on CD that asks you questions and
produces the configuration files. It had better be a JAWS app since
it would be out of date before it hit the shelves.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,965
Messages
2,570,148
Members
46,710
Latest member
FredricRen

Latest Threads

Top