Here you can find the source of createTestData()
static void createTestData() throws Exception
//package com.java2s; /******************************************************************************* * Copyright (c) 2004 Actuate Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* w w w. jav a2s . c o m*/ * Actuate Corporation - initial API and implementation *******************************************************************************/ import java.sql.DriverManager; public class Main { /** Data types to be tested */ final static String[] DATA_TYPES = new String[] { "decimal", "date", "float", "int", "varchar(100)", "time", "timestamp" }; /** Data values for the test */ final static String[][] DATA_VALUES = new String[][] { { "NULL", "'2000-01-01 00:00:00'", "0.0", "0", "'00'", "'1900-01-01 12:00:01'", "'2000-01-01 12:00:00'" }, { "1111", "NULL", "1.1", "1", "'11'", "'1900-01-01 12:00:01'", "'2001-01-01 12:00:00'" }, { "2222", "'2002-01-01 00:00:00'", "NULL", "2", "'22'", "'1900-01-01 12:00:02'", "'2002-01-01 12:00:00'" }, { "3333", "'2003-01-01 00:00:00'", "3.3", "NULL", "'33'", "'1900-01-01 12:00:03'", "'2003-01-01 12:00:00'" }, { "4444", "'2004-01-01 00:00:00'", "4.4", "4", "NULL", "'1900-01-01 12:00:04'", "'2004-01-01 12:00:00'" }, { "5555", "'2005-01-01 00:00:00'", "5.5", "5", "'55'", "NULL", "'2005-01-01 12:00:00'" }, { "6666", "'2006-01-01 00:00:00'", "6.6", "6", "'66'", "'1900-01-01 12:00:06'", "NULL" } }; /** Test table name */ final static String TABLE_NAME = "\"test_oda_jdbc\""; static void createTestData() throws Exception { java.sql.Connection jdbcConn = openJDBCConnection(); java.sql.Statement jdbcStmt = jdbcConn.createStatement(); String sql = "drop table " + TABLE_NAME; try { jdbcStmt.execute(sql); } catch (Exception e) { } sql = "create table " + TABLE_NAME + "("; for (int i = 0; i < DATA_TYPES.length; i++) { if (i > 0) { sql += ", "; } sql += ("col" + i + " " + DATA_TYPES[i]); } sql += ")"; jdbcStmt.execute(sql); for (int i = 0; i < DATA_VALUES.length; i++) { sql = "insert into " + TABLE_NAME + " values("; for (int j = 0; j < DATA_VALUES[i].length; j++) { if (j > 0) sql += ", "; sql += DATA_VALUES[i][j]; } sql += ")"; jdbcStmt.execute(sql); } jdbcStmt.close(); jdbcConn.close(); } static java.sql.Connection openJDBCConnection() throws Exception { Class.forName(getDriverClassName()); java.sql.Connection jdbcConn = DriverManager.getConnection(getURL(), getUser(), getPassword()); return jdbcConn; } static String getDriverClassName() { return "org.apache.derby.jdbc.EmbeddedDriver"; } static String getURL() { String url = System.getProperty("DTETest.url"); if (url != null) return url; else return "jdbc:derby:" + getDatabase() + ";create=true;user=" + getUser() + ";password=" + getPassword(); } static String getUser() { String user = System.getProperty("DTETest.user"); if (user != null) return user; else return "Actuate"; } static String getPassword() { String pwd = System.getProperty("DTETest.password"); if (pwd != null) return pwd; else return "Actuate"; } static String getDatabase() { String database = System.getProperty("DTETest.database"); if (database != null) return database; else return "DTETest"; } }