Hello,
The code bellow works fine on Windows tomcat but doesn't on Linux.
I recompiled it. Could you give me any idea why it is so?
It thrown null pointer exception on if line.
I know that before calling dbconn.getConnection() i should check wheather is
dbconn != null.
If it is because of Tomcats settings where and what should i change to make
it work?
thx,
Kanar
DBConnection dbconn=(DBConnection)session.getAttribute("dbconn");
if(dbconn.getConnection() != null){//session didn't expired
....
}
Palle Mogensen - 10 Sep 2003 22:53 GMT
Hi KS.
dbconn is null. Therefore dbconn.getConnection() will give
NullPointerException.
The correction syntax is:
DBConnection dbconn=(DBConnection)session.getAttribute("dbconn");
if(dbconn!=null && dbconn.getConnection() != null){//session didn't expired
....
}
regards
Palle
> Hello,
>
[quoted text clipped - 13 lines]
> ....
> }
Palle Mogensen - 10 Sep 2003 23:09 GMT
Hi KS.
The reason why dbconn is null must be when setting the session attribute.
Perhaps you got a ClassNotFound exception there. Are you sure that
DBConnection class is in the classpath for the Tomcat?
regards
Palle
> Hello,
>
[quoted text clipped - 13 lines]
> ....
> }
KS - 11 Sep 2003 18:45 GMT
Strange thing.
I didn't change anythig in the code or in the Tomcat or system settings and
it started working OK after 8 hours.
I don't know why, but it works now.
thx for your interest in helping me,
Krzysiek
> Hi KS.
>
[quoted text clipped - 23 lines]
> > ....
> > }
Carlo Pellegrini - 12 Sep 2003 09:02 GMT
> Strange thing.
> I didn't change anythig in the code or in the Tomcat or system settings and
> it started working OK after 8 hours.
> I don't know why, but it works now.
Be careful, when you store an Object in a session, it must
be Serializable.....
The Connection interface doesn't enforce it.
You should rely on the Tomcat connection pooling facility
instead:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
Regards,
CarloP