Обсуждение: JDBC getConnection with Tomcat
I'm sorry for the posting, but recently re-installed my development machine to Win XP from Win 2000. I had everything working fine with Win 2000. My issue is when I go the query the database from my jsp page I receive this HTTP Status 500 error:
Exception
javax.servlet.ServletException
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
. . .
root cause
java.lang.NullPointerException
fssm.dao.UnitDAO.getUnit(UnitDAO.java:104)
fssm.manager.UnitManager.HqsUnit(UnitManager.java:22)
Here is what's on line 104 of UnitDAO.java:
. . .
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{
conn = getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(GET_HQ_UNITS_SQL);
. . .
Any suggestion for what I should check. I'm thinking I have a path problem. My web.xml points to an application.xml file in CATALINA_HOME\conf\Catalina\localhost directory.
Thank you,
Warren
> On 6/30/06, Murray Warren <murray_warren@bah.com> wrote: > I'm sorry for the posting, but recently re-installed my development machine > to Win XP from Win 2000. I had everything working fine with Win 2000. My > issue is when I go the query the database from my jsp page I receive this > HTTP Status 500 error: If we can't help you, it may be better to post to Tomcat mailing lists. (But for all I know, they sent you here.) 1. Can you connect to the database with psql.exe on the command prompt, pgAdmin, or any other tool? 2. Did you remember to put the appropriate JDBC driver class (postgresql.jar works, I've heard others work) in the Tomcat classpath? 3. Does your xml configuration file have the right settings for the connection? Mine has <Realm className="org.apache.catalina.realm.JDBCRealm" connectionName="<username>" connectionPassword="<password>" connectionURL="jdbc:postgresql://192.168.2.61:5432/<mydatabase>" driverName="org.postgresql.Driver" roleNameCol="categoryname" userCredCol="password" userNameCol="username" userRoleTable="logincategory_view" userTable="login_view" debug="99"/> Of course, all values inside <> (except for the opening and closing greater than and less than) have the appropriate values filled in. Good luck! -Mike Swierczek > > Exception > javax.servlet.ServletException > > org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523) > . . . > > > root cause > java.lang.NullPointerException > fssm.dao.UnitDAO.getUnit(UnitDAO.java:104) > > fssm.manager.UnitManager.HqsUnit(UnitManager.java:22) > > Here is what's on line 104 of UnitDAO.java: > > . . . > Connection conn = null; > Statement stmt = null; > ResultSet rs = null; > > try > { > conn = getConnection(); > stmt = conn.createStatement(); > > rs = stmt.executeQuery(GET_HQ_UNITS_SQL); > . . . > > Any suggestion for what I should check. I'm thinking I have a path problem. > My web.xml points to an application.xml file in > CATALINA_HOME\conf\Catalina\localhost directory. > > Thank you, > Warren