Here you can find the source of executeDDL(final Connection connection, final String sql, final int... ignoreErrors)
Parameter | Description |
---|---|
connection | Connection to execute statement |
sql | DDL statement |
ignoreErrors | Firebird error codes to ignore |
Parameter | Description |
---|---|
SQLException | SQLException for executing statement, except for errors with the error code listed in<code>ignoreErrors</code> |
public static void executeDDL(final Connection connection, final String sql, final int... ignoreErrors) throws SQLException
//package com.java2s; /*// w ww . j a v a2 s . co m * Firebird Open Source JavaEE Connector - JDBC Driver * * Distributable under LGPL license. * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * LGPL License for more details. * * This file was created by members of the firebird development team. * All individual contributions remain the Copyright (C) of those * individuals. Contributors to this file are either listed here or * can be obtained from a source control history command. * * All rights reserved. */ import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import java.util.Arrays; public class Main { /** * Helper method for executing DDL (or technically: any statement), ignoring the specified list of error codes. * * @param connection * Connection to execute statement * @param sql * DDL statement * @param ignoreErrors * Firebird error codes to ignore * @throws SQLException * SQLException for executing statement, except for errors with the error code listed in * <code>ignoreErrors</code> * @see org.firebirdsql.gds.ISCConstants */ public static void executeDDL(final Connection connection, final String sql, final int... ignoreErrors) throws SQLException { if (ignoreErrors != null) { Arrays.sort(ignoreErrors); } try (Statement stmt = connection.createStatement()) { stmt.execute(sql); } catch (SQLException ex) { if (ignoreErrors == null || ignoreErrors.length == 0) throw ex; for (Throwable current : ex) { if (current instanceof SQLException && Arrays.binarySearch(ignoreErrors, ((SQLException) current).getErrorCode()) >= 0) { return; } } throw ex; } } }