Here you can find the source of createDBWithTB(String db)
public static void createDBWithTB(String db) throws SQLException
//package com.java2s; //License from project: Apache License import java.sql.*; public class Main { public static final String path = System.getProperty("user.dir") + "/src/test/resources/h2db"; public static final String userName = "root"; public static final String pass = "xujianhai"; public static final String CREATETB0 = " create table tb0(" + " order_id INT NOT NULL," + " product_id INT NOT NULL," + " usr_id INT NOT NULL," + " begin_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP," + " end_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP," + " status INT," + " PRIMARY KEY(order_id)" + " )"; public static final String CREATETB1 = " create table tb1(" + " order_id INT NOT NULL," + " product_id INT NOT NULL," + " usr_id INT NOT NULL," + " begin_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP," + " end_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP," + " status INT," + " PRIMARY KEY(order_id)" + " )"; public static void createDBWithTB(String db) throws SQLException { Connection conn = DriverManager.getConnection("jdbc:h2:" + path + ":" + db, userName, pass); boolean flag; Statement statement;/*w ww . j a v a 2s . c o m*/ // tb0 statement = conn.createStatement(); flag = statement.execute(CREATETB0); assert flag; // tb1 statement = conn.createStatement(); flag = statement.execute(CREATETB1); assert flag; conn.close(); } }