Here you can find the source of createHSQLTables(LineNumberReader reader, Statement statement)
private static void createHSQLTables(LineNumberReader reader, Statement statement) throws IOException, SQLException
//package com.java2s; //License from project: Open Source License import java.sql.Statement; import java.sql.SQLException; import java.io.*; import java.util.regex.Pattern; import java.util.regex.Matcher; public class Main { private static Pattern pattern = Pattern.compile("\\s*(\\w+)\\s+(\\w+)\\s+.*"); private static void createHSQLTables(LineNumberReader reader, Statement statement) throws IOException, SQLException { String line;//from w w w . j a va 2 s. co m int idx = 0; String addPkLine = null; String createTableLine = null; StringBuffer stringBuffer = new StringBuffer(1000); while (null != (line = reader.readLine())) { if (line.startsWith("alter table ")) { // do nothing } else { if (line.startsWith("create table ")) { createTableLine = (line + "\n"); stringBuffer.append(createTableLine); addPkLine = null; } /* else if (line.startsWith("drop")) { stringBuffer.append(line+";\n"); try { statement.execute(stringBuffer.toString()); } catch (Exception e) { logger.error("Error running SQL-statement: "+ line,e); } stringBuffer = new StringBuffer(1000); } */ else if (line.startsWith("drop") || line.startsWith("alter") || line.startsWith(")") || line.startsWith("create sequence")) { /* if (line.indexOf("reportchange")!=-1) { stringBuffer = new StringBuffer(1000); continue; } */ if (addPkLine != null) { // stringBuffer.append(",\n"+addPkLine+"\n"); addPkLine = null; } stringBuffer.append(line + ";\n"); statement.execute(stringBuffer.toString()); stringBuffer = new StringBuffer(1000); } else if (line.indexOf("generated by default as identity (start with 1),") != -1) { Matcher matcher = pattern.matcher(line); matcher.matches(); stringBuffer.append("\t" + matcher.group(1) + " " + matcher.group(2) + ",\n"); addPkLine = " primary key (" + matcher.group(1) + ")"; } else { stringBuffer.append(line + "\n"); } } idx++; } } }