package com.ctrip.platform.dal.daogen.utils; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class ResourceUtils { public static void close(Connection conn){ try { if(null != conn) conn.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void close(ResultSet rs){ try { if(null != rs) rs.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void close(Statement stat){ try { if(null != stat) stat.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void close(PreparedStatement stat){ try { if(null != stat) stat.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void rollback(Connection conn){ try { if(null != conn){ conn.rollback(); conn.setAutoCommit(true); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }