Skip site navigation (1) Skip section navigation (2)

Re: Servlet problems

From: "Jayesh K(dot) Parayali" <jparayali(at)TOTALFLOOD(dot)com>
To: "PostgreSQL JDBC" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Servlet problems
Date: 2001-12-17 17:44:51
Message-ID: 8ACB76BF6B98C94FB6959B660C051BA50C9C09@PACIFIC.TOTALFLOOD.COM (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Use try/catch/finally blocks. Make sure that you close your connection
in finally block.
  try {
    all ur code goes here
  catch (SQLException e) {
    print exception
  catch (Exception e) {
    print exception
  finally {
    try {
     close resultset
     close statement
     close connection
    catch (SQLException e) {


-----Original Message-----
From: Antonio Fiol BonnĂ­n [mailto:fiol(at)w3ping(dot)com]
Sent: Monday, December 17, 2001 6:55 AM
To: Nikola Milutinovic
Cc: PostgreSQL JDBC
Subject: Re: [JDBC] Servlet problems


I'm afraid I don't speak JSP ;-) but I may siggest something.

Can you try to flush every output you send?

For every println(), if you use them, just place a flush() immediately 
after it. That WILL NOT solve your problem, and WILL degrade 
performance, but MAY help you find the source for your trouble. Once 
your problem is solved (I let you do the hard work), you can safely take

them away.

Good luck!


Nikola Milutinovic wrote:

>Hi all.
>I'm a bit confused here. I'm using Tomcat JSP/Servlet engine. I have a
database in PostgreSQL, which holds a table describing an n-tree
structure (hierarchy). I would like my JSP page to able to display (if
parameter "print" is present) a complete sub-tree of a given node. This
is a simple recursion. What I'm trying to do is make our coroporate
E-Mail address book, so I have organizational units and users.
>Without recursion everything works fine, all the direct subnodes are
displayed. When I use recusrion to include all subnodes, I get strange
>First, it was killing the response in the middile of a table, in the
middle of a row. Now it dies with "NullPointerException: next()". In
other words, in one of the "" methods, it runs into a
non existant ResultSet.
>I have tried putting a "breakpoint" (throwing a ServletException) on
all lines of my JSP page. When there is a "breakpoint" I do not run into
a NullPointerException. When I remove it, I have exception.
>My conclusion was that I get the error AFTER my JSP page starts
emerging from the recursion (if it was inside recursion, it would have
been stopped by the "breakpoint"). So, after a page calls itself once,
the "insider" does it's thing and then exits and releases control to
it's caller, the the exception occurs.
>I must admit that JSP page closes it's JDBC objects, I thought it would
be OK, since the page creates them.
>This is the flow of events:
>OUDisplay.jsp [instance 1]:
>  DriverManager.getConnection()
>  Connection.createStatement()
>  Statement.executeQuery()
>  while( ) {
>    ...
>    <jsp.include page="OUDisplay.jsp" />
>    OUDisplay.jsp [instance 2]:
>    ----------------------------
>      DriverManager.getConnection()
>      Connection.createStatement()
>      Statement.executeQuery()
>      while( ) {
>        ...
>      }
>      ResultSet.close()
>      Statement.close()
>      Connection.close()
>    --------------[instance 2]-
>  }
>  ResultSet.close()
>  Statement.close()
>  Connection.close()
>--------------[instance 1]-
>The problem occurs inside the outer "next() {...}", which leads me to
believe that Some objects in the "instance 1" get screwed up, but I
don't know how.
>Any insight?
>---------------------------(end of
>TIP 3: if posting/reading through Usenet, please send an appropriate
>subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
>message can get through to the mailing list cleanly

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

pgsql-jdbc by date

Next:From: Rene PijlmanDate: 2001-12-17 23:08:18
Subject: Re: JDK 1.4 challenge, opinions please
Previous:From: Ned WolpertDate: 2001-12-17 16:46:41
Subject: Re: JDK 1.4 challenge, opinions please

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group