密文数据源联接发池 ConnectionTools 02

密文数据源连接发池 ConnectionTools 02
/**
     * 关闭Connection 2011-12-30,Xgw123485
     */
    public static void closeConn(Connection conn)
    {
        if (conn != null)
        {
            try
            {
                conn.close();
            }
            catch (Exception e)
            {
                logger.error("close db Connection failure");
                conn = null;
            }
        }
    }

    /**
     * Close PreparedStatement
     */
    public static void closeStmt(PreparedStatement stmt)
    {
        if(stmt!=null)
        {
            try
            {
                stmt.close();
            }
            catch (Exception e)
            {
                logger.error("close PreparedStatement failure.");
                stmt=null;
            }
        }
    }
   
    /**
     * close ResultSet
     */
    public static void closeResult(ResultSet rs)
    {
        if(rs!=null)
        {
            try
            {
                rs.close();
            }
            catch (Exception e)
            {
                logger.error("Close ResultSet failure.");
                rs=null;
            }
        }
    }
    public static void main(String[] args) {
        Connection connection = getConnection();
        try {
            Statement statement = connection.createStatement();
            statement.executeQuery("select 1 from dual");

            statement.close();
            connection.close();
        } catch (SQLException e) {

            e.printStackTrace();
        }
    }
}