Try putting try-catch block for close methods in finally block .. Dont forget to print stack.
2009/3/24 Ondrej Medek <xmed...@gmail.com> > > Hi, > > I use JDBC in a stateless session bean in JBoss. (I know it's a bad > practice.) I get the connection via the JBoss DataSource: > > try { > InitialContext ic = new InitialContext(); > dataSource = (DataSource) ic.lookup("java:/testDS"); > Connecion conn = dataSource.getConnection(); > > PreparedStatement ps = ... > ResultSet rs = ps.executeStatemet(); > > } catch (SQLException e) { > LOG(...); > throw new EJBException(e); > } finally { > DBUtils.close(rs); > DBUtils.close(ps); > DBUtils.close(conn); > } > > > I am not sure, whether is it the right thing to close all JDBC > resources in the finally clause? AFAIK the container makes a rollback > in case of any exception. But I do not know, if the container also > cleans everything up as well? Could be sufficient just the following > code? > > > try { > InitialContext ic = new InitialContext(); > dataSource = (DataSource) ic.lookup("java:/testDS"); > Connecion conn = dataSource.getConnection(); > > PreparedStatement ps = ... > ResultSet rs = ps.executeStatemet(); > > rs.close(); > ps.close(); > conn.close(); > } catch (SQLException e) { > LOG(...); > throw new EJBException(e); > } > > Thank you > Andy > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en -~----------~----~----~----~------~----~------~--~---