package com.chenyang.nse.bussiness.test;

import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Db2test {
   public static void main(String[] args) throws ClassNotFoundException, SQLException, UnsupportedEncodingException {
      String url = "jdbc:db2://192.168.2.216:50000/ghca";
      String driver = "com.ibm.db2.jcc.DB2Driver";
      String passwd = "db2inst1";
      String user = "db2inst1";
      Class.forName(driver);
      Connection conn = DriverManager.getConnection(url, passwd, user);
      PreparedStatement ps = null;
      createTable(conn, ps);
      ps.close();
      conn.close();
      System.out.println("over");
   }

   public static void createTable(Connection conn, PreparedStatement ps) throws SQLException {
      String sql = "CREATE TABLE YSL.EXPLAIN_STREAM(\tEXPLAIN_REQUESTER VARCHAR(128) NOT NULL,EXPLAIN_TIME TIMESTAMP NOT NULL,SOURCE_NAME VARCHAR(128) NOT NULL,SOURCE_SCHEMA VARCHAR(128) NOT NULL,SOURCE_VERSION VARCHAR(64) NOT NULL,EXPLAIN_LEVEL CHAR(1) NOT NULL,STMTNO INTEGER NOT NULL,SECTNO INTEGER NOT NULL,STREAM_ID INTEGER,SOURCE_TYPE CHAR(1),SOURCE_ID INTEGER,TARGET_TYPE CHAR(1),TARGET_ID INTEGER,OBJECT_SCHEMA VARCHAR(128),OBJECT_NAME VARCHAR(128),STREAM_COUNT DOUBLE,COLUMN_COUNT SMALLINT,PREDICATE_ID INTEGER,COLUMN_NAMES CLOB,PMID SMALLINT,SINGLE_NODE CHAR(5),PARTITION_COLUMNS CLOB,SEQUENCE_SIZES CLOB) ";
      ps = conn.prepareStatement(sql);
      ps.execute();
   }
}
