Java Code Examples for java.sql.CallableStatement#setBoolean()

The following examples show how to use java.sql.CallableStatement#setBoolean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GfxdDistributedSystemBridge.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void enableStatementStats(boolean enableOrDisableStats,
    boolean enableOrDisableTimeStats) {
  CallableStatement globalStatsEnableStatement;
  try {
    if (connectionWrapperHolder.hasConnection()) {
      EmbedConnection connection = connectionWrapperHolder.getConnection();
      globalStatsEnableStatement = connection
          .prepareCall("CALL SYS.SET_GLOBAL_STATEMENT_STATISTICS(?, ?)");
      globalStatsEnableStatement.setBoolean(1, enableOrDisableStats);
      globalStatsEnableStatement.setBoolean(2, enableOrDisableTimeStats);
      globalStatsEnableStatement.execute();
    } else {
      this.logger.info(LocalizedStrings.DEBUG,
          "For cluster does not have connection: ");
    }
  } catch (SQLException e) {
    this.logger.info(LocalizedStrings.DEBUG,
        "Error occurred while enabling statement stats for cluster. Reason: "
            + e.getMessage());
  }
}
 
Example 2
Source File: DatabaseMetaDataTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method for testing getBestRowIdentifier - calls the ODBC procedure
 * @throws SQLException
 */
private ResultSet getBestRowIdentifierODBC(String catalog, String schema,
    String table, int scope, boolean nullable) throws SQLException
{
    CallableStatement cs = prepareCall(
        "CALL SYSIBM.SQLSPECIALCOLUMNS(1, ?, ?, ?, ?, ?, " +
    "'DATATYPE=''ODBC''')");
    cs.setString(1, catalog);
    cs.setString(2, schema);
    cs.setString(3, table);
    cs.setInt(4, scope);
    cs.setBoolean(5, nullable);

    cs.execute();
    return cs.getResultSet();
}
 
Example 3
Source File: DatabaseMetaDataTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method for testing getIndexInfo - calls the ODBC procedure
 * @throws SQLException
 */
private ResultSet getIndexInfoODBC(String catalog, String schema,
    String table, boolean unique, boolean approximate) throws SQLException
{
    CallableStatement cs = prepareCall(
            "CALL SYSIBM.SQLSTATISTICS(?, ?, ?, ?, ?, " +
            "'DATATYPE=''ODBC''')");

    cs.setString(1, catalog);
    cs.setString(2, schema);
    cs.setString(3, table);
    // the unique parameter needs to be flopped...See the call
    // in SystemProcedures.
    cs.setBoolean(4, unique? false : true);
    cs.setBoolean(5, approximate);

    cs.execute();
    return cs.getResultSet();
}
 
Example 4
Source File: GfxdDistributedSystemBridge.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void enableStatementStats(boolean enableOrDisableStats,
    boolean enableOrDisableTimeStats) {
  CallableStatement globalStatsEnableStatement;
  try {
    if (connectionWrapperHolder.hasConnection()) {
      EmbedConnection connection = connectionWrapperHolder.getConnection();
      globalStatsEnableStatement = connection
          .prepareCall("CALL SYS.SET_GLOBAL_STATEMENT_STATISTICS(?, ?)");
      globalStatsEnableStatement.setBoolean(1, enableOrDisableStats);
      globalStatsEnableStatement.setBoolean(2, enableOrDisableTimeStats);
      globalStatsEnableStatement.execute();
    } else {
      this.logger.info(LocalizedStrings.DEBUG,
          "For cluster does not have connection: ");
    }
  } catch (SQLException e) {
    this.logger.info(LocalizedStrings.DEBUG,
        "Error occurred while enabling statement stats for cluster. Reason: "
            + e.getMessage());
  }
}
 
Example 5
Source File: DatabaseMetaDataTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method for testing getIndexInfo - calls the ODBC procedure
 * @throws SQLException
 */
private ResultSet getIndexInfoODBC(String catalog, String schema,
    String table, boolean unique, boolean approximate) throws SQLException
{
    CallableStatement cs = prepareCall(
            "CALL SYSIBM.SQLSTATISTICS(?, ?, ?, ?, ?, " +
            "'DATATYPE=''ODBC''')");

    cs.setString(1, catalog);
    cs.setString(2, schema);
    cs.setString(3, table);
    // the unique parameter needs to be flopped...See the call
    // in SystemProcedures.
    cs.setBoolean(4, unique? false : true);
    cs.setBoolean(5, approximate);

    cs.execute();
    return cs.getResultSet();
}
 
Example 6
Source File: DatabaseMetaDataTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method for testing getBestRowIdentifier - calls the ODBC procedure
 * @throws SQLException
 */
private ResultSet getBestRowIdentifierODBC(String catalog, String schema,
    String table, int scope, boolean nullable) throws SQLException
{
    CallableStatement cs = prepareCall(
        "CALL SYSIBM.SQLSPECIALCOLUMNS(1, ?, ?, ?, ?, ?, " +
    "'DATATYPE=''ODBC''')");
    cs.setString(1, catalog);
    cs.setString(2, schema);
    cs.setString(3, table);
    cs.setInt(4, scope);
    cs.setBoolean(5, nullable);

    cs.execute();
    return cs.getResultSet();
}
 
Example 7
Source File: StatementPlanWithNativeTimerDUnit.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void setNativeNanoTimer() throws SQLException {
  Connection conn = TestUtil.getConnection();
  CallableStatement st = conn
      .prepareCall("CALL SYS.SET_NANOTIMER_TYPE(?, ?)");
  st.setBoolean(1, true);
  st.setString(2, "CLOCK_PROCESS_CPUTIME_ID");
  st.execute();
}
 
Example 8
Source File: WanTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected void startGatewayHub() {
  Connection conn = getGFEConnection();
  Log.getLogWriter().info("starting the gateway hub_" + myWanSite);
  try {
    CallableStatement cs = conn.prepareCall("CALL SYS.START_GATEWAY_HUB(?,?)");
    cs.setString(1, "hub_" + myWanSite);
    cs.setBoolean(2, true);  //TODO, to test stratGatway when set as false (not starting gateway
    cs.execute();
    Log.getLogWriter().info("gateway hub_" + myWanSite +" is started.");
  } catch (SQLException se) {
    SQLHelper.handleSQLException(se);
  }
}
 
Example 9
Source File: StatementPlanWithNativeTimerDUnit.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void setNativeNanoTimer() throws SQLException {
  Connection conn = TestUtil.getConnection();
  CallableStatement st = conn
      .prepareCall("CALL SYS.SET_NANOTIMER_TYPE(?, ?)");
  st.setBoolean(1, true);
  st.setString(2, "CLOCK_PROCESS_CPUTIME_ID");
  st.execute();
}
 
Example 10
Source File: GemFireXDPlatform.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
protected void writeAllDDLs(Connection conn, Writer writer, boolean exportAll)
    throws SQLException, IOException {
  CallableStatement cstmt = conn.prepareCall("call SYS.EXPORT_DDLS(?)");
  cstmt.setBoolean(1, exportAll);
  ResultSet rs = cstmt.executeQuery();
  while (rs.next()) {
    writer.write(rs.getString(3));
    writer.write(';');
    writer.write(SqlBuilder.LINE_SEPARATOR);
    writer.write(SqlBuilder.LINE_SEPARATOR);
  }
  rs.close();
  writer.flush();
}
 
Example 11
Source File: WanTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected void startGatewayHub() {
  Connection conn = getGFEConnection();
  Log.getLogWriter().info("starting the gateway hub_" + myWanSite);
  try {
    CallableStatement cs = conn.prepareCall("CALL SYS.START_GATEWAY_HUB(?,?)");
    cs.setString(1, "hub_" + myWanSite);
    cs.setBoolean(2, true);  //TODO, to test stratGatway when set as false (not starting gateway
    cs.execute();
    Log.getLogWriter().info("gateway hub_" + myWanSite +" is started.");
  } catch (SQLException se) {
    SQLHelper.handleSQLException(se);
  }
}
 
Example 12
Source File: GemFireXDPlatform.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
protected void writeAllDDLs(Connection conn, Writer writer, boolean exportAll)
    throws SQLException, IOException {
  CallableStatement cstmt = conn.prepareCall("call SYS.EXPORT_DDLS(?)");
  cstmt.setBoolean(1, exportAll);
  ResultSet rs = cstmt.executeQuery();
  while (rs.next()) {
    writer.write(rs.getString(3));
    writer.write(';');
    writer.write(SqlBuilder.LINE_SEPARATOR);
    writer.write(SqlBuilder.LINE_SEPARATOR);
  }
  rs.close();
  writer.flush();
}
 
Example 13
Source File: StatementPlanWithNativeTimerDUnit.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void testNanoTimerSPs() throws Exception {
  startVMs(1, 3);
  Connection conn = TestUtil.getConnection();

  ResultSet rs = conn.createStatement()
      .executeQuery("values SYS.GET_NATIVE_NANOTIMER_TYPE()");
  assertTrue(rs.next());
  String defaultTimeType = rs.getString(1);
  assertFalse(rs.next());

  setNativeNanoTimer();

  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_IS_NATIVE_NANOTIMER()", null, "true");
  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_NATIVE_NANOTIMER_TYPE()", null,
      "CLOCK_PROCESS_CPUTIME_ID");

  CallableStatement st = conn
      .prepareCall("CALL SYS.SET_NANOTIMER_TYPE(?, ?)");
  st.setBoolean(1, true);
  st.setString(2, "CLOCK_REALTIME");
  st.execute();

  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_IS_NATIVE_NANOTIMER()", null, "true");
  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_NATIVE_NANOTIMER_TYPE()", null, "CLOCK_REALTIME");

  // check reset to default
  st = conn.prepareCall("CALL SYS.SET_NANOTIMER_TYPE(?, ?)");
  st.setBoolean(1, true);
  st.setString(2, "DEFAULT");
  st.execute();

  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_IS_NATIVE_NANOTIMER()", null, "false");
  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_NATIVE_NANOTIMER_TYPE()", null, defaultTimeType);

  // check reset to non-native default MONOTONIC type
  st = conn.prepareCall("CALL SYS.SET_NANOTIMER_TYPE(?, ?)");
  st.setBoolean(1, false);
  st.setString(2, "CLOCK_THREAD_CPUTIME_ID");
  st.execute();

  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_IS_NATIVE_NANOTIMER()", null, "false");
  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_NATIVE_NANOTIMER_TYPE()", null, "CLOCK_MONOTONIC");
}
 
Example 14
Source File: WanTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
protected void addGateway() {
  //setting gateway queue
  Connection conn = getGFEConnection();    
  boolean enableQueuePersistence = (Boolean)bb.getSharedMap().get("enableQueuePersistence");
  Log.getLogWriter().info("adding Gateway");
 
  for (int i=1; i<= numOfWanSites; i++) {
    if (i != myWanSite) {
      try {
        CallableStatement cs1 = conn.prepareCall("CALL SYS.ADD_GATEWAY(?, ?)");
        CallableStatement cs2 = conn.prepareCall("CALL SYS.CONFIGURE_GATEWAY_QUEUE(?,?,?,?,?,?,?,?,?)");

        cs1.setString(1, "hub_" + myWanSite);
        cs1.setString(2, gatewayID+i);
        cs1.execute();
        commit(conn);
        Log.getLogWriter().info("gateway " + gatewayID+i + " is created for hub_" + myWanSite);
             
        cs2.setString(1, "hub_" + myWanSite);
        cs2.setString(2, gatewayID+i);
        cs2.setNull(3,Types.INTEGER); //BATCH_SIZE
        cs2.setNull(4,Types.INTEGER); //BATCH_TIME_INTERVAL
        cs2.setBoolean(5,enableQueueConflation);  //BATCH_CONFLATION, default to false -- can be used to check listener invocation
        cs2.setNull(6, Types.INTEGER);  //MAXIMUM_QUEUE_MEMORY in megabytes
        if (random.nextBoolean()) {
          cs2.setNull(7, Types.VARCHAR); //DIR_PATH
          Log.getLogWriter().info("no specific diskstore provided");
        }
        else {
          cs2.setString(7, diskStore);
        }
        cs2.setBoolean(8, enableQueuePersistence);  //ENABLE_PERSISTENCE   
        cs2.setNull(9, Types.INTEGER); //ALTRERT_THRESHOLD default is 0
        cs2.execute();          
        commit(conn);
        Log.getLogWriter().info("Gateway and gateway queue are added");
      } catch (SQLException se) {
       SQLHelper.handleSQLException(se);
      }
    }
  }
}
 
Example 15
Source File: WanTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
protected void createGatewayHub(Connection conn, String hubID, 
    String hostname, String sg, int portIndex) {
  int hubPort = -1;
  int[] freeTCPPorts = null;
  try {
          
    CallableStatement cs = conn
        .prepareCall("CALL SYS.ADD_GATEWAY_HUB(?,?, ?,?,?,?,?)");
    if (wanBB.getSharedCounters().incrementAndRead(SQLWanBB.synchWanEndPorts) ==1) {
      //only one thread will add wan ports to bb
      freeTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(numOfWanSites * numOfDataStoresPerSite);
      SQLWanBB.getBB().getSharedMap().put("wanEndPoints", freeTCPPorts);
      StringBuilder ports = new StringBuilder();
      for (int port: freeTCPPorts) {
        ports.append(port + ", ");
      }
      Log.getLogWriter().info("Free TCP ports are :" + ports.toString());
    } 
    freeTCPPorts = (int[]) SQLWanBB.getBB().getSharedMap().get("wanEndPoints");
    while (freeTCPPorts == null){
      MasterController.sleepForMs(300);
      freeTCPPorts = (int[]) SQLWanBB.getBB().getSharedMap().get("wanEndPoints");
    }
    hubPort = freeTCPPorts[(myWanSite - 1) * numOfDataStoresPerSite +  (portIndex-1)];  
    //myWanSite starts from 1, each data store (different SG) in the site 
    //portIndex starts from 1
    
    //cs.setString(1, serverGroup.toString());
    cs.setString(1, sg);//
    cs.setString(2, hubID);
    cs.setInt(3, hubPort);
    cs.setNull(4, Types.INTEGER);
    cs.setNull(5, Types.INTEGER);
    
    int startupPolicy = random.nextInt(3);
    if (startupPolicy ==0) cs.setNull(6, Types.VARCHAR);
    else if (startupPolicy == 1) cs.setString(6, "primary");
    else {
      cs.setString(6, "secondary");
      Log.getLogWriter().info("trying to become secondaary");
    }
    
    //manual start
    if (random.nextBoolean()) cs.setNull(7, Types.BOOLEAN);
    else {
      cs.setBoolean(7, true);
      Log.getLogWriter().info("Need to manually start hub");
    }
    cs.execute();
  } catch (SQLException se) {
    SQLHelper.handleSQLException(se);
  }
  
  ArrayList<Integer> hubPorts = (ArrayList<Integer>) bb.getSharedMap().get("portID_wanSite"+myWanSite);
  if (hubPorts == null) hubPorts = new ArrayList<Integer>();
  hubPorts.add(hubPort);
  bb.getSharedMap().put("portID_wanSite"+myWanSite, hubPorts); //setup port number
  bb.getSharedMap().put("hostname_wanSite"+myWanSite, hostname);  //for multi hosts
  Log.getLogWriter().info("my wan site is " + myWanSite);
  //Log.getLogWriter().info("server group that hub is created on is " + serverGroup.toString());
  Log.getLogWriter().info("server group that hub is created on is " + sg);
  Log.getLogWriter().info("the hub created on port " + hubPort);
}
 
Example 16
Source File: StatementPlanWithNativeTimerDUnit.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void testNanoTimerSPs() throws Exception {
  startVMs(1, 3);
  Connection conn = TestUtil.getConnection();

  ResultSet rs = conn.createStatement()
      .executeQuery("values SYS.GET_NATIVE_NANOTIMER_TYPE()");
  assertTrue(rs.next());
  String defaultTimeType = rs.getString(1);
  assertFalse(rs.next());

  setNativeNanoTimer();

  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_IS_NATIVE_NANOTIMER()", null, "true");
  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_NATIVE_NANOTIMER_TYPE()", null,
      "CLOCK_PROCESS_CPUTIME_ID");

  CallableStatement st = conn
      .prepareCall("CALL SYS.SET_NANOTIMER_TYPE(?, ?)");
  st.setBoolean(1, true);
  st.setString(2, "CLOCK_REALTIME");
  st.execute();

  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_IS_NATIVE_NANOTIMER()", null, "true");
  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_NATIVE_NANOTIMER_TYPE()", null, "CLOCK_REALTIME");

  // check reset to default
  st = conn.prepareCall("CALL SYS.SET_NANOTIMER_TYPE(?, ?)");
  st.setBoolean(1, true);
  st.setString(2, "DEFAULT");
  st.execute();

  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_IS_NATIVE_NANOTIMER()", null, "false");
  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_NATIVE_NANOTIMER_TYPE()", null, defaultTimeType);

  // check reset to non-native default MONOTONIC type
  st = conn.prepareCall("CALL SYS.SET_NANOTIMER_TYPE(?, ?)");
  st.setBoolean(1, false);
  st.setString(2, "CLOCK_THREAD_CPUTIME_ID");
  st.execute();

  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_IS_NATIVE_NANOTIMER()", null, "false");
  sqlExecuteVerify(new int[] { 1 }, new int[] { 1, 2, 3 },
      "values SYS.GET_NATIVE_NANOTIMER_TYPE()", null, "CLOCK_MONOTONIC");
}
 
Example 17
Source File: WanTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
protected void createGatewayHub(Connection conn, String hubID, 
    String hostname, String sg, int portIndex) {
  int hubPort = -1;
  int[] freeTCPPorts = null;
  try {
          
    CallableStatement cs = conn
        .prepareCall("CALL SYS.ADD_GATEWAY_HUB(?,?, ?,?,?,?,?)");
    if (wanBB.getSharedCounters().incrementAndRead(SQLWanBB.synchWanEndPorts) ==1) {
      //only one thread will add wan ports to bb
      freeTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(numOfWanSites * numOfDataStoresPerSite);
      SQLWanBB.getBB().getSharedMap().put("wanEndPoints", freeTCPPorts);
      StringBuilder ports = new StringBuilder();
      for (int port: freeTCPPorts) {
        ports.append(port + ", ");
      }
      Log.getLogWriter().info("Free TCP ports are :" + ports.toString());
    } 
    freeTCPPorts = (int[]) SQLWanBB.getBB().getSharedMap().get("wanEndPoints");
    while (freeTCPPorts == null){
      MasterController.sleepForMs(300);
      freeTCPPorts = (int[]) SQLWanBB.getBB().getSharedMap().get("wanEndPoints");
    }
    hubPort = freeTCPPorts[(myWanSite - 1) * numOfDataStoresPerSite +  (portIndex-1)];  
    //myWanSite starts from 1, each data store (different SG) in the site 
    //portIndex starts from 1
    
    //cs.setString(1, serverGroup.toString());
    cs.setString(1, sg);//
    cs.setString(2, hubID);
    cs.setInt(3, hubPort);
    cs.setNull(4, Types.INTEGER);
    cs.setNull(5, Types.INTEGER);
    
    int startupPolicy = random.nextInt(3);
    if (startupPolicy ==0) cs.setNull(6, Types.VARCHAR);
    else if (startupPolicy == 1) cs.setString(6, "primary");
    else {
      cs.setString(6, "secondary");
      Log.getLogWriter().info("trying to become secondaary");
    }
    
    //manual start
    if (random.nextBoolean()) cs.setNull(7, Types.BOOLEAN);
    else {
      cs.setBoolean(7, true);
      Log.getLogWriter().info("Need to manually start hub");
    }
    cs.execute();
  } catch (SQLException se) {
    SQLHelper.handleSQLException(se);
  }
  
  ArrayList<Integer> hubPorts = (ArrayList<Integer>) bb.getSharedMap().get("portID_wanSite"+myWanSite);
  if (hubPorts == null) hubPorts = new ArrayList<Integer>();
  hubPorts.add(hubPort);
  bb.getSharedMap().put("portID_wanSite"+myWanSite, hubPorts); //setup port number
  bb.getSharedMap().put("hostname_wanSite"+myWanSite, hostname);  //for multi hosts
  Log.getLogWriter().info("my wan site is " + myWanSite);
  //Log.getLogWriter().info("server group that hub is created on is " + serverGroup.toString());
  Log.getLogWriter().info("server group that hub is created on is " + sg);
  Log.getLogWriter().info("the hub created on port " + hubPort);
}
 
Example 18
Source File: WanTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
protected void addGateway() {
  //setting gateway queue
  Connection conn = getGFEConnection();    
  boolean enableQueuePersistence = (Boolean)bb.getSharedMap().get("enableQueuePersistence");
  Log.getLogWriter().info("adding Gateway");
 
  for (int i=1; i<= numOfWanSites; i++) {
    if (i != myWanSite) {
      try {
        CallableStatement cs1 = conn.prepareCall("CALL SYS.ADD_GATEWAY(?, ?)");
        CallableStatement cs2 = conn.prepareCall("CALL SYS.CONFIGURE_GATEWAY_QUEUE(?,?,?,?,?,?,?,?,?)");

        cs1.setString(1, "hub_" + myWanSite);
        cs1.setString(2, gatewayID+i);
        cs1.execute();
        commit(conn);
        Log.getLogWriter().info("gateway " + gatewayID+i + " is created for hub_" + myWanSite);
             
        cs2.setString(1, "hub_" + myWanSite);
        cs2.setString(2, gatewayID+i);
        cs2.setNull(3,Types.INTEGER); //BATCH_SIZE
        cs2.setNull(4,Types.INTEGER); //BATCH_TIME_INTERVAL
        cs2.setBoolean(5,enableQueueConflation);  //BATCH_CONFLATION, default to false -- can be used to check listener invocation
        cs2.setNull(6, Types.INTEGER);  //MAXIMUM_QUEUE_MEMORY in megabytes
        if (random.nextBoolean()) {
          cs2.setNull(7, Types.VARCHAR); //DIR_PATH
          Log.getLogWriter().info("no specific diskstore provided");
        }
        else {
          cs2.setString(7, diskStore);
        }
        cs2.setBoolean(8, enableQueuePersistence);  //ENABLE_PERSISTENCE   
        cs2.setNull(9, Types.INTEGER); //ALTRERT_THRESHOLD default is 0
        cs2.execute();          
        commit(conn);
        Log.getLogWriter().info("Gateway and gateway queue are added");
      } catch (SQLException se) {
       SQLHelper.handleSQLException(se);
      }
    }
  }
}
 
Example 19
Source File: ParameterMetaDataJdbc30Test.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
    * Testing a callable statement by calling a SQL procedure with 
    * boolean IN parameters, OUT parameters and IN_OUT parameters.
    */
public void testBooleanProcedureArgs() throws Exception
   {
       Statement stmt = createStatement();

       stmt.executeUpdate("create procedure booleanProc" + 
                          "( in inarg boolean, out outarg boolean, inout inoutarg boolean )" + 
                          "language java external name "+ 
                          "'com.splicemachine.dbTesting.functionTests." +
                          "tests.jdbcapi.ParameterMetaDataJdbc30Test.booleanProc' " +
                          "parameter style java");
       
       CallableStatement cs = prepareCall("CALL booleanProc(?,?,?)");
       cs.registerOutParameter(2,Types.BOOLEAN);
       cs.registerOutParameter(3,Types.BOOLEAN);

       //verify the meta data for the parameters
       ParameterMetaData paramMetaData = cs.getParameterMetaData();
	assertEquals("Unexpected parameter count", 3, paramMetaData.getParameterCount());
       
	//expected values to be stored in a 2dim. array	
	String [][] parameterMetaDataArray0 =
           {
               //isNullable, isSigned, getPrecision, getScale, getParameterType, getParameterTypeName, getParameterClassName, getParameterMode
               {"PARAMETER_NULLABLE", "false", "1", "0", "16", "BOOLEAN", "java.lang.Boolean", "PARAMETER_MODE_IN"},
               {"PARAMETER_NULLABLE", "false", "1", "0", "16", "BOOLEAN", "java.lang.Boolean", "PARAMETER_MODE_OUT"},
               {"PARAMETER_NULLABLE", "false", "1", "0", "16", "BOOLEAN", "java.lang.Boolean", "PARAMETER_MODE_IN_OUT"},
           };
       
	testParameterMetaData(paramMetaData, parameterMetaDataArray0);

       cs.setBoolean( 1,  true );
       cs.setBoolean( 3, true );
       cs.execute();
       assertEquals( true, cs.getBoolean( 2 ) );
       assertEquals( false, cs.getBoolean( 3 ) );

       cs.setObject( 1,  Boolean.FALSE );
       cs.setObject( 3, Boolean.FALSE );
       cs.execute();
       assertEquals( false, cs.getBoolean( 2 ) );
       assertEquals( true, cs.getBoolean( 3 ) );

	stmt.close();
	cs.close();
}