Skip to content

Instantly share code, notes, and snippets.

@aslakhellesoy
Created April 16, 2018 12:30
Show Gist options
  • Save aslakhellesoy/f3dd2632047df42dec71d1192f3262f4 to your computer and use it in GitHub Desktop.
Save aslakhellesoy/f3dd2632047df42dec71d1192f3262f4 to your computer and use it in GitHub Desktop.
public class JdbcSchema {
public static void createTables(Connection connection) throws SQLException, URISyntaxException, IOException {
// Stupid Scanner trick: https://community.oracle.com/blogs/pat/2004/10/23/stupid-scanner-tricks
String sql = new Scanner(JdbcSchema.class.getResourceAsStream("sqlite.sql"), "UTF-8").useDelimiter("\\A").next();
for (String stmt : sql.split("-- 8< --")) {
connection.createStatement().executeUpdate(stmt);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment