diff --git a/data/h2gis/src/test/groovy/org/orbisgis/data/GroovyH2GISTest.groovy b/data/h2gis/src/test/groovy/org/orbisgis/data/GroovyH2GISTest.groovy index 87f0ab41..a1be8c77 100644 --- a/data/h2gis/src/test/groovy/org/orbisgis/data/GroovyH2GISTest.groovy +++ b/data/h2gis/src/test/groovy/org/orbisgis/data/GroovyH2GISTest.groovy @@ -419,10 +419,10 @@ class GroovyH2GISTest { """) def file = new File('target/myscript.sql') file.delete() - file << 'CREATE TABLE super as SELECT * FROM h2gis;\n --COMMENTS HERE \nSELECT * FROM super;' + file << 'CREATE TABLE super as SELECT * FROM h2gis;\n --COMMENTS HERE \nALTER TABLE super RENAME to super_rename;' h2GIS.executeScript("target/myscript.sql") def concat = "" - h2GIS.getSpatialTable "super" eachRow { row -> concat += "$row.id $row.the_geom $row.geometry\n" } + h2GIS.getSpatialTable "super_rename" eachRow { row -> concat += "$row.id $row.the_geom $row.geometry\n" } assertEquals("1 POINT (10 10) POINT (10 10)\n2 POINT (1 1) POINT (1 1)\n", concat) } diff --git a/data/jdbc/src/main/java/org/orbisgis/data/jdbc/JdbcDataSource.java b/data/jdbc/src/main/java/org/orbisgis/data/jdbc/JdbcDataSource.java index ceed4b8a..43a7ff5d 100644 --- a/data/jdbc/src/main/java/org/orbisgis/data/jdbc/JdbcDataSource.java +++ b/data/jdbc/src/main/java/org/orbisgis/data/jdbc/JdbcDataSource.java @@ -566,10 +566,11 @@ public void eachRow(GString gstring, @Override public boolean executeScript(String fileName, Map bindings) throws Exception { + boolean b = false; try { File file = URIUtilities.fileFromString(fileName); if (FileUtilities.isExtensionWellFormated(file, "sql")) { - boolean b = executeScript(new FileInputStream(file), bindings); + b = executeScript(new FileInputStream(file), bindings); if (!getConnection().getAutoCommit()) { super.commit(); } @@ -583,8 +584,9 @@ public boolean executeScript(String fileName, Map bindings) thro } catch (SQLException e2) { throw new SQLException("Unable to rollback.", e2); } + throw e; } - return false; + return b; } @Override @@ -610,17 +612,16 @@ public boolean executeScript(InputStream stream, Map bindings) t } } try { - boolean b = execute(commandSQL); + execute(commandSQL); if (!getConnection().getAutoCommit()) { super.commit(); } - return b; } catch (SQLException e) { throw new SQLException("Unable to execute the Sql command '" + commandSQL + "'.\n" + e.getLocalizedMessage()); } } } - return false; + return true; } @Override