From c7dd83a639df933949ddd68b41ce6912fde37af7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Tue, 13 Sep 2016 11:19:40 +0200 Subject: [PATCH] SONAR-8025 add DbTester#executeDdl --- sonar-db/src/test/java/org/sonar/db/DbTester.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sonar-db/src/test/java/org/sonar/db/DbTester.java b/sonar-db/src/test/java/org/sonar/db/DbTester.java index f56843dd329..0cc9726cf98 100644 --- a/sonar-db/src/test/java/org/sonar/db/DbTester.java +++ b/sonar-db/src/test/java/org/sonar/db/DbTester.java @@ -30,6 +30,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; +import java.sql.Statement; import java.util.Collections; import java.util.List; import java.util.Locale; @@ -149,6 +150,15 @@ public class DbTester extends ExternalResource { } } + public void executeDdl(String ddl) { + try (Connection connection = getConnection(); + Statement stmt = connection.createStatement()) { + stmt.execute(ddl); + } catch (SQLException e) { + throw new IllegalStateException("Failed to execute DDL: " + ddl, e); + } + } + /** * Very simple helper method to insert some data into a table. * It's the responsibility of the caller to convert column values to string. -- 2.39.5