import hiro.yoshioka.ast.sql.util.BindInfo;
import hiro.yoshioka.sql.DataBaseFactory;
import hiro.yoshioka.sql.HSQL;
import hiro.yoshioka.sql.engine.SQLServerThread;
import hiro.yoshioka.sql.params.ConnectionProperties;
import hiro.yoshioka.sql.params.ConnectionSettingBean;

import java.io.File;
import java.sql.SQLException;

public class HsqlBlob {
	static File winConnections = new File(
			"C:/tools/eclipse/wk/WolfSQLParser/config/");

	public static void main(String[] args) {
		SQLServerThread.getSQLServer().init(winConnections);
		ConnectionSettingBean bean = SQLServerThread.getSQLServer()
				.getConnectionSettingBean();
		System.out.println("bean=" + bean);
		ConnectionProperties targetHsqlConnectionProperties = bean
				.getLocalHsqlServerConnection();
		HSQL hsql = DataBaseFactory.createHSQL();
		try {
			hsql.connect(targetHsqlConnectionProperties);
			// hsql.execute("CREATE TABLE BIN_TEST(id integer, b binary)");
			BindInfo[] binds = new BindInfo[2];
			binds[0] = new BindInfo("id");
			binds[0].setValue("2");
			binds[0].setTypeString("NUMERIC");
			binds[1] = new BindInfo("b");
			binds[1].setTypeString("BINARY");
			binds[1].setValue("C:/tmp/sample_Suicaのペンギン.jpg");
			hsql.executePrepare("insert into bin_test(id,b) values(?,?)", binds);
			hsql.commit();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
