/*******************************************************************************
 * Copyright (c) 2004, 2005 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: Actuate Corporation - initial API and implementation
 ******************************************************************************/

package org.eclipse.birt.data.engine.odaconsumer;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

final class TestSetup
{
    private static String url = "jdbc:derby:DtETest";
	private static String username = "sa";
	private static String password = "sa";
	private static String driverclass = "org.apache.derby.jdbc.EmbeddedDriver";
    
	public static void createTestTable() throws Exception
	{
		Class.forName( driverclass ); // load the specified driver

		Connection connection = DriverManager.getConnection( url+";create=true",
				username,
				password );
		Statement statement = connection.createStatement( );
		try
		{
		    statement.execute( "drop table \"testtable\"");	
		    statement.execute( "drop table \"testtable_lob\"");	
		}catch (SQLException e)
		{
		}
		statement.execute( "CREATE TABLE \"testtable\"( \"intColumn\" INT, \"doubleColumn\" FLOAT(52), "
				+ "\"stringColumn\" VARCHAR(50), \"dateColumn\" DATE, \"decimalColumn\" DECIMAL(18,0) )" );
		statement.execute( "INSERT INTO \"testtable\" VALUES( 123, 1.212312, 'blah blah blah', "
				+ "'2000-09-01', 600 )" );
		statement.execute( "INSERT INTO \"testtable\" VALUES( 14, 3.14, 'hahahahahahhahaha', "
				+ "'1991-10-02', 10 )" );
		statement.execute( "INSERT INTO \"testtable\" VALUES( 0, 1.23, 'niem', "
				+ "'1979-11-28', 10 )" );
		statement.execute( "INSERT INTO \"testtable\" VALUES( NULL, NULL, NULL, "
				+ "NULL, NULL )" );
		statement.execute( "INSERT INTO \"testtable\" VALUES( 4, 12.3636, 'seven zero six', "
				+ "'2004-01-01', 10000 )" );
		
		statement.execute( "CREATE TABLE \"testtable_lob\"( \"blob1\" BLOB, \"clob1\" CLOB )" );
		statement.execute( "INSERT INTO \"testtable_lob\" VALUES( NULL, 'abcdefg' )" );
				
		statement.close( );		
		connection.close( );
	}
}