package org.sfm.jdbc.mysql;


import java.sql.*;


public class MysqlDbHelper {
	

	public static Connection objectDb() throws SQLException {
		Connection c = newMysqlDbConnection();
		
		Statement st = c.createStatement();

		try {
			createDbObject(st);

		} finally {
			st.close();
		}

		return c;
	}


	
	private static void createDbObject(Statement st) throws SQLException {
		st.execute("create table IF NOT EXISTS test_db_object("
				+ " id bigint primary key,"
				+ " name varchar(100), "
				+ " email varchar(100),"
				+ " creation_Time DATETIME, type_ordinal int, type_name varchar(10)  )");


		st.execute("create table IF NOT EXISTS test_db_object_autoinc("
				+ " id bigint AUTO_INCREMENT primary key,"
				+ " name varchar(100), "
				+ " email varchar(100),"
				+ " creation_Time DATETIME, type_ordinal int, type_name varchar(10)  )");

		st.execute("create table IF NOT EXISTS test_db_object_ckey("
				+ " id bigint,"
				+ " name varchar(100), "
				+ " email varchar(100),"
				+ " creation_Time DATETIME, type_ordinal int, type_name varchar(10), primary key(id, name)  )");
	}


	private static Connection newMysqlDbConnection() throws SQLException {
		String user = "sfm";

		if ("true".equals(System.getenv("TRAVISBUILD"))) {
			user = "travis";
		}

		return DriverManager.getConnection("jdbc:mysql://localhost:3306/sfm", user, null);
	}

	public static void main(String[] args) throws SQLException {
		Connection connection = MysqlDbHelper.objectDb();

		System.out.println("product name  = " + connection.getMetaData().getDatabaseProductName());
		System.out.println("product name  = " + connection.getMetaData().getDatabaseProductVersion());
		System.out.println("product name  = " + connection.getMetaData().getDatabaseMajorVersion());
		System.out.println("product name  = " + connection.getMetaData().getDatabaseMinorVersion());

	}


}

@@ -443,30 +443,30 @@
  EXISTS 
-test_db_object
+TEST_DB_OBJECT
 (%22%0D%0A%09%09%09%09
@@ -682,30 +682,30 @@
 STS 
-test_db_object_autoinc
+TEST_DB_OBJECT_AUTOINC
 (%22%0D%0A
@@ -938,27 +938,27 @@
 STS 
-test_db_object_ckey
+TEST_DB_OBJECT_CKEY
 (%22%0D%0A

fix mysql test