Code example for Connection

Methods: close, getMetaData

0
	 * @param connection 
	 */ 
	public static void closeConnection(Connection connection) {
		if (connection != null) {
			try { 
				connection.close();
			} catch (SQLException e) {
				throw new RuntimeException(e);
			} 
		} 
	} 
 
	/** 
	 * @param statement 
	 */ 
	public static void closeStatement(Statement statement) {
		if (statement != null) {
			try { 
				statement.close();
			} catch (SQLException e) {
				throw new RuntimeException(e);
			} 
		} 
	} 
 
	/** 
	 * @param resultSet 
	 */ 
	public static void closeResultSet(ResultSet resultSet) {
		if (resultSet != null) {
			try { 
				resultSet.close();
			} catch (SQLException e) {
				throw new RuntimeException(e);
			} 
		} 
	} 
 
	/** 
	 * @param dataSource 
	 * @param tableName 
	 * @return 
	 * @throws SQLException 
	 */ 
	public static boolean isTableExist(DataSource dataSource, String tableName)
			throws SQLException { 
		Connection connection = null;
		ResultSet resultSet = null;
		try { 
			connection = dataSource.getConnection();
			DatabaseMetaData metaData = connection.getMetaData();
			resultSet = metaData.getTables(connection.getCatalog(), null,
					tableName, new String[] { "TABLE" });
			if (resultSet.next()) {
				return true; 
			}