This design looks good. I'm going to add the finally. I don't mean to harp on the point but how is it that the connection would be null if I'm never setting it to null. I see some problems which appear to be related to connections not getting closed and I'm worried that the problem I'm having with closing the connection is causing this.
Kim -----Original Message----- From: Robert Parker [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 18, 2001 5:23 PM To: Struts Users Mailing List Subject: Re: Poolman question Whilst we're on the exception handling design, you could consider the following design... The point is that under all circumstances, you want to close your resources, so consider putting them in a finally block. That way you don't have to duplicate your close statements... try { ... } catch(SQLException e) { ... } finally { try { if (null != conn) { conn.close(); } ... } catch(Exception) { } } ----- Original Message ----- From: "MacKellar, Kimberly" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Wednesday, December 19, 2001 9:57 AM Subject: RE: Poolman question > I'm not sure how my connection could be null at the point I try to close it. > Following is one of the methods where I'm having this problem. If I > uncomment the conn.close() in the try block, I get the exception I sent > earlier. > public static Vector getFileTypeIdList() { > Vector results = new Vector(); > > Connection conn = null; > > try { > conn = Database.getConnection(); > > CallableStatement stmt = > conn.prepareCall(GET_FILE_TYPE_ID_LIST); > > stmt.registerOutParameter(1, OracleTypes.CURSOR); > stmt.execute(); > ResultSet rs = (ResultSet)stmt.getObject(1); > > while(rs.next()) { > > results.add(rs.getString(FieldMappingsFileType.FILE_TYPE_ID)); > } > > //conn.close(); > //conn = null; > } > catch (SQLException sqle) { > cat.error("getFileTypeIdList: " + sqle.getMessage()); > try { > if(!conn.isClosed()) { > //conn.close(); > //conn = null; > } > } > catch(SQLException sqle1) { > cat.fatal("getFileTypeIdList: " + sqle1.getMessage()); > } > } > > if(results.size() > 0) { > return results; > } > else { > return null; > } > } > > -----Original Message----- > From: Nathan Anderson [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, December 18, 2001 4:35 PM > To: Struts Users Mailing List > Subject: RE: Poolman question > > > When you call "conn.close()" it can throw an SQLException so you should put > it in a try catch block with an empty catch. But this is not the problem > you have. In your case conn is already null. So you should have something > like this: > > try { > if (resultSet!=null) resultSet.close(); > if (statement!=null) statement.close(); > if (connection!=null) connection.close(); > } catch (SQLException sqle) { } > > Hope that helps :) > > Nathan Anderson > > > > -----Original Message----- > From: MacKellar, Kimberly [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, December 18, 2001 2:16 PM > To: Struts-User (E-mail) > Subject: Poolman question > > > I know this is off subject but I can't find a poolman mailing list and I > know there are people on this list using Poolman... > I'm running struts-1.0 on a windowNT machine with tomcat-3.2.3. I have > multiple webapps running under the same server. I just set up a new webapp > that uses poolman. The problem is that when I try to access the datasource > I've configured in the new webapp, poolman appears to be looking in other > webapps' WEB-INF/classes directory for the poolman.xml file and isn't > finding the data source for the new webapp. Has anyone else seen this or > know how to fix it? > Also when I try to call conn.close() (conn is of type Connection) I get the > following exception: > java.lang.NullPointerException > at java.util.Hashtable.containsKey(Hashtable.java:299) > at com.codestudio.util.JDBCPool.returnPooledStatement(Unknown > Source) > at com.codestudio.sql.PoolManPreparedStatement.close(Unknown Source) > at com.codestudio.util.JDBCPool.closeStatement(Unknown Source) > at com.codestudio.sql.PoolManConnection.clean(Unknown Source) > at com.codestudio.util.JDBCPool.returnConnection(Unknown Source) > at com.codestudio.util.JDBCPool.connectionClosed(Unknown Source) > at com.codestudio.sql.PoolManConnection.sendCloseEvent(Unknown > Source) > at com.codestudio.sql.PoolManConnectionHandle.close(Unknown Source) > at > com.tfp.admintool.database.FileTypeDatabase.getFieldList(FileTypeDatabase.ja > va:256) > at > com.tfp.admintool.fileType.EditTagListAction.performAction(EditTagListAction > .java:56) > at > com.tfp.admintool.ValidatedAction.perform(ValidatedAction.java:40) > at > org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.ja > va:1786) > at > org.apache.struts.action.ActionServlet.process(ActionServlet.java:1585) > at > org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:509) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > at > org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405) > at org.apache.tomcat.core.Handler.service(Handler.java:287) > at > org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) > at > org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:81 > 2) > at > org.apache.tomcat.core.ContextManager.service(ContextManager.java:758) > at > org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC > onnectionHandler.java:213) > at > org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) > at > org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501) > at java.lang.Thread.run(Thread.java:484) > > > Kimberly MacKellar > Thomson Financial Publishing > [EMAIL PROTECTED] > (847) 933-8005 > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>