Java Code Examples for java.sql.SQLNonTransientException

The following examples show how to use java.sql.SQLNonTransientException. These examples are extracted from open source projects. 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 Project: dble   Source File: RouterUtil.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * no shard-ing table dataNode
 *
 * @param schemaConfig the SchemaConfig info
 * @param tableName    the TableName
 * @return dataNode DataNode of no-sharding table
 */
public static String isNoSharding(SchemaConfig schemaConfig, String tableName) throws SQLNonTransientException {
    if (schemaConfig == null || ProxyMeta.getInstance().getTmManager().getSyncView(schemaConfig.getName(), tableName) instanceof QueryNode) {
        return null;
    }
    if (schemaConfig.isNoSharding()) { //schema without table
        return schemaConfig.getDataNode();
    }
    TableConfig tbConfig = schemaConfig.getTables().get(tableName);
    if (tbConfig == null && schemaConfig.getDataNode() != null) {
        return schemaConfig.getDataNode();
    }
    if (tbConfig != null && tbConfig.isNoSharding()) {
        return tbConfig.getDataNodes().get(0);
    }
    return null;
}
 
Example 2
Source Project: dble   Source File: DefaultDruidParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public SchemaConfig visitorParse(SchemaConfig schemaConfig, RouteResultset rrs, SQLStatement stmt, ServerSchemaStatVisitor visitor, ServerConnection sc, boolean isExplain)
        throws SQLException {
    stmt.accept(visitor);
    if (visitor.getNotSupportMsg() != null) {
        throw new SQLNonTransientException(visitor.getNotSupportMsg());
    }
    String schemaName = null;
    if (schemaConfig != null) {
        schemaName = schemaConfig.getName();
    }
    Map<String, String> tableAliasMap = getTableAliasMap(schemaName, visitor.getAliasMap());
    ctx.setRouteCalculateUnits(ConditionUtil.buildRouteCalculateUnits(visitor.getAllWhereUnit(), tableAliasMap, schemaName));

    return schemaConfig;
}
 
Example 3
Source Project: jaybird   Source File: TestJnaBlob.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Test double open is not allowed.
 */
@Test
public void testOutputBlobDoubleOpen() throws Exception {
    expectedException.expect(SQLNonTransientException.class);
    expectedException.expect(allOf(
            errorCodeEquals(ISCConstants.isc_segstr_no_op),
            fbMessageStartsWith(ISCConstants.isc_segstr_no_op)
    ));

    try (JnaDatabase db = createDatabaseConnection()) {
        final FbTransaction transaction = getTransaction(db);
        try {
            final FbBlob blob = db.createBlobForOutput(transaction, null);
            blob.open();
            blob.open();
        } finally {
            transaction.commit();
        }
    }
}
 
Example 4
/**
 * Checks if this statement is not in {@link StatementState#CLOSED}, {@link StatementState#CLOSING},
 * {@link StatementState#NEW} or {@link StatementState#ERROR}, and throws an <code>SQLException</code> if it is.
 *
 * @throws SQLException
 *         When this statement is closed or in error state.
 */
protected final void checkStatementValid() throws SQLException {
    switch (getState()) {
    case NEW:
        // TODO Externalize sqlstate
        // TODO See if there is a firebird error code matching this (isc_cursor_not_open is not exactly the same)
        throw new SQLNonTransientException("Statement not yet allocated", "24000");
    case CLOSING:
    case CLOSED:
        // TODO Externalize sqlstate
        // TODO See if there is a firebird error code matching this (isc_cursor_not_open is not exactly the same)
        throw new SQLNonTransientException("Statement closed", "24000");
    case ERROR:
        // TODO SQLState?
        // TODO See if there is a firebird error code matching this
        throw new SQLNonTransientException("Statement is in error state and needs to be closed");
    default:
        // Valid state, continue
        break;
    }
}
 
Example 5
Source Project: dble   Source File: RouterUtil.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static boolean findRouterWithConditionsForTable(
        RouteResultset rrs, Map<Pair<String, String>, Set<String>> tablesRouteMap,
        Pair<String, String> table, TableConfig tableConfig,
        Map<String, ColumnRoute> columnsMap) throws SQLNonTransientException {
    String joinKey = tableConfig.getJoinKey();
    String partitionCol = tableConfig.getPartitionColumn();
    boolean isFoundPartitionValue = partitionCol != null && columnsMap.get(partitionCol) != null;

    // where filter contains partition column
    if (isFoundPartitionValue) {
        ColumnRoute partitionValue = columnsMap.get(partitionCol);
        Set<String> dataNodeSet = ruleCalculate(rrs, tableConfig, partitionValue, rrs.isComplexSQL());
        if (dataNodeSet.size() > 0) {
            tablesRouteMap.computeIfAbsent(table, k -> new HashSet<>());
            tablesRouteMap.get(table).addAll(dataNodeSet);
        }
    } else if (joinKey != null && columnsMap.get(joinKey) != null) {
        routerForJoinTable(rrs, tableConfig, columnsMap, joinKey);
        return true;
    } else {
        //no partition column,router to all nodes
        tablesRouteMap.computeIfAbsent(table, k -> new HashSet<>());
        tablesRouteMap.get(table).addAll(tableConfig.getDataNodes());
    }
    return false;
}
 
Example 6
@Override
public SqlCountHolder getSqlCounts() throws SQLException {
    try {
        checkStatementValid();
        if (getState() == StatementState.CURSOR_OPEN && !isAllRowsFetched()) {
            // We disallow fetching count when we haven't fetched all rows yet.
            // TODO SQLState
            throw new SQLNonTransientException("Cursor still open, fetch all rows or close cursor before fetching SQL counts");
        }
    } catch (SQLException e) {
        exceptionListenerDispatcher.errorOccurred(e);
        throw e;
    }
    final SqlCountProcessor countProcessor = createSqlCountProcessor();
    // NOTE: implementation of SqlCountProcessor assumes the specified size is sufficient (actual requirement is 49 bytes max) and does not handle truncation
    final SqlCountHolder sqlCounts = getSqlInfo(countProcessor.getRecordCountInfoItems(), 64, countProcessor);
    statementListenerDispatcher.sqlCounts(this, sqlCounts);
    return sqlCounts;
}
 
Example 7
Source Project: Mycat2   Source File: DruidMysqlHavingTest.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testHaving() throws SQLNonTransientException {
	String sql = "select avg(offer_id) avgofferid, member_id from offer_detail group by member_id having avgofferid > 100";
	SchemaConfig schema = schemaMap.get("cndb");
       RouteResultset rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,
               null, cachePool);
       Assert.assertEquals(3, rrs.getSqlMerge().getHavingColsName().length);

	sql = "select avg(offer_id) avgofferid, member_id from offer_detail group by member_id having avg(offer_id) > 100";
       rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,
               null, cachePool);
       Assert.assertEquals(3, rrs.getSqlMerge().getHavingColsName().length);

       sql = "select count(offer_id) countofferid, member_id from offer_detail group by member_id having countofferid > 100";
       rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,
               null, cachePool);
       Assert.assertEquals(3, rrs.getSqlMerge().getHavingColsName().length);

       sql = "select count(offer_id) countofferid, member_id from offer_detail group by member_id having count(offer_id) > 100";
       rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,
               null, cachePool);
       Assert.assertEquals(3, rrs.getSqlMerge().getHavingColsName().length);

}
 
Example 8
Source Project: dble   Source File: InsertHandler.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void handle(DumpFileContext context, SQLStatement sqlStatement) throws InterruptedException {
    MySqlInsertStatement insert = (MySqlInsertStatement) sqlStatement;
    SQLInsertStatement.ValuesClause valueClause;

    valuesHandler.preProcess(context);
    for (int i = 0; i < insert.getValuesList().size(); i++) {
        valueClause = insert.getValuesList().get(i);
        try {
            processIncrementColumn(context, valueClause.getValues());
            valuesHandler.process(context, valueClause.getValues(), i == 0);
        } catch (SQLNonTransientException e) {
            context.addError(e.getMessage());
        }
    }
    valuesHandler.postProcess(context);
}
 
Example 9
Source Project: dble   Source File: RouterUtil.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static boolean tryRouteNoShardingTablesToOneNode(Set<String> tmpResultNodes, Set<Pair<String, String>> tablesSet, Pair<String, String> table, String schemaName, String tableName, SchemaConfig schema) throws SQLNonTransientException {
    //may view
    if (ProxyMeta.getInstance().getTmManager().getSyncView(schemaName, tableName) != null) {
        return true;
    }
    if (schema.getDataNode() == null) {
        String msg = " Table '" + schemaName + "." + tableName + "' doesn't exist";
        LOGGER.info(msg);
        throw new SQLNonTransientException(msg);
    } else {
        tmpResultNodes.add(schema.getDataNode());
        tablesSet.remove(table);
        if (tmpResultNodes.size() != 1) {
            return true;
        }
    }
    return false;
}
 
Example 10
Source Project: dble   Source File: RouterUtil.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * findRouterForMultiSchemaTables
 */
private static void findRouterForMultiSchemaTables(
        Map<Pair<String, String>, SchemaConfig> schemaMap, RouteResultset rrs,
        Map<Pair<String, String>, Map<String, ColumnRoute>> tablesAndConditions,
        Map<Pair<String, String>, Set<String>> tablesRouteMap) throws SQLNonTransientException {

    //router for shard-ing tables
    for (Map.Entry<Pair<String, String>, Map<String, ColumnRoute>> entry : tablesAndConditions.entrySet()) {
        Pair<String, String> table = entry.getKey();
        String tableName = table.getValue();
        SchemaConfig schema = schemaMap.get(table);
        TableConfig tableConfig = schema.getTables().get(tableName);
        if (tableConfig != null && !tableConfig.isGlobalTable() && schema.getTables().get(tableName).getDataNodes().size() != 1) {
            //shard-ing table,childTable or others
            if (findRouterWithConditionsForTable(rrs, tablesRouteMap, table, tableConfig, entry.getValue()))
                return;
        }
    }
}
 
Example 11
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLNonTransientException ex = new SQLNonTransientException("Exception 1", t1);
    SQLNonTransientException ex1 = new SQLNonTransientException("Exception 2");
    SQLNonTransientException ex2 = new SQLNonTransientException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
Example 12
Source Project: dble   Source File: DruidLockTableParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void handleSingleViewLock(Map<String, Set<String>> dataNodeToLocks, PlanNode viewQuery, String alias, MySqlLockTableStatement.LockType lockType, String schemaName) throws SQLNonTransientException {
    Map<String, Set<String>> tableMap = new HashMap<>();
    findTableInPlanNode(tableMap, viewQuery, schemaName);
    for (Map.Entry<String, Set<String>> entry : tableMap.entrySet()) {
        SchemaConfig schemaConfig = DbleServer.getInstance().getConfig().getSchemas().get(entry.getKey());
        for (String table : entry.getValue()) {
            TableConfig tableConfig = schemaConfig.getTables().get(table);
            if (tableConfig != null) {
                handleConfigTable(dataNodeToLocks, tableConfig, alias == null ? null : "view_" + alias + "_" + table, lockType);
            } else if (ProxyMeta.getInstance().getTmManager().getSyncTableMeta(schemaConfig.getName(), table) != null) {
                handleNoshardTable(dataNodeToLocks, table, schemaConfig.getDataNode(), alias == null ? null : "view_" + alias + "_" + table, lockType);
            } else {
                String msg = "Table '" + schemaConfig.getName() + "." + table + "' doesn't exist";
                LOGGER.info(msg);
                throw new SQLNonTransientException(msg);
            }
        }
    }
    return;
}
 
Example 13
Source Project: nifi   Source File: PutHiveQL.java    License: Apache License 2.0 5 votes vote down vote up
@OnScheduled
public void constructProcess() {
    exceptionHandler = new ExceptionHandler<>();
    exceptionHandler.mapException(e -> {
        if (e instanceof SQLNonTransientException) {
            return ErrorTypes.InvalidInput;
        } else if (e instanceof SQLException) {
            // Use the SQLException's vendor code for guidance -- see Hive's ErrorMsg class for details on error codes
            int errorCode = ((SQLException) e).getErrorCode();
            getLogger().debug("Error occurred during Hive operation, Hive returned error code {}", new Object[]{errorCode});
            if (errorCode >= 10000 && errorCode < 20000) {
                return ErrorTypes.InvalidInput;
            } else if (errorCode >= 20000 && errorCode < 30000) {
                return ErrorTypes.InvalidInput;
            } else if (errorCode >= 30000 && errorCode < 40000) {
                return ErrorTypes.TemporalInputFailure;
            } else if (errorCode >= 40000 && errorCode < 50000) {
                // These are unknown errors (to include some parse errors), but rather than generating an UnknownFailure which causes
                // a ProcessException, we'll route to failure via an InvalidInput error type.
                return ErrorTypes.InvalidInput;
            } else {
                // Default unknown errors to TemporalFailure (as they were implemented originally), so they can be routed to failure
                // or rolled back depending on the user's setting of Rollback On Failure.
                return ErrorTypes.TemporalFailure;
            }
        } else {
            return ErrorTypes.UnknownFailure;
        }
    });
    exceptionHandler.adjustError(RollbackOnFailure.createAdjustError(getLogger()));

    process = new Put<>();
    process.setLogger(getLogger());
    process.initConnection(initConnection);
    process.fetchFlowFiles(fetchFlowFiles);
    process.putFlowFile(putFlowFile);
    process.adjustRoute(RollbackOnFailure.createAdjustRoute(REL_FAILURE, REL_RETRY));
}
 
Example 14
Source Project: Mycat2   Source File: DefaultDruidParser.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 使用MycatSchemaStatVisitor解析,得到tables、tableAliasMap、conditions等
 * @param schema
 * @param stmt
 */
public void parser(SchemaConfig schema, RouteResultset rrs, SQLStatement stmt, String originSql,LayerCachePool cachePool,MycatSchemaStatVisitor schemaStatVisitor) throws SQLNonTransientException {
	ctx = new DruidShardingParseInfo();
	//设置为原始sql,如果有需要改写sql的,可以通过修改SQLStatement中的属性,然后调用SQLStatement.toString()得到改写的sql
	ctx.setSql(originSql);
	//通过visitor解析
	visitorParse(rrs,stmt,schemaStatVisitor);

	//通过Statement解析
	statementParse(schema, rrs, stmt);
}
 
Example 15
@Override
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
	try {
	    String targetString = CharStreams.toString(reader);
	    reader.close();
	    
	    setString(parameterIndex, targetString);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		throw new SQLNonTransientException(e);
	}
	
}
 
Example 16
/**
 * Create SQLNonTransientException and setting all objects to null
 */
@Test
public void test() {
    SQLNonTransientException e = new SQLNonTransientException(null,
            null, errorCode, null);
    assertTrue(e.getMessage() == null && e.getSQLState() == null
            && e.getCause() == null && e.getErrorCode() == errorCode);
}
 
Example 17
Source Project: jaybird   Source File: JnaDatabase.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void executeImmediate(String statementText, FbTransaction transaction) throws SQLException {
    // TODO also implement op_exec_immediate2
    try {
        if (isAttached()) {
            if (transaction == null) {
                throw FbExceptionBuilder
                        .forException(JaybirdErrorCodes.jb_executeImmediateRequiresTransactionAttached)
                        .toFlatSQLException();
            } else if (!(transaction instanceof JnaTransaction)) {
                // TODO SQLState and/or Firebird specific error
                throw new SQLNonTransientException(
                        String.format("Invalid transaction handle type: %s, expected: %s",
                        transaction.getClass(), JnaTransaction.class));
            }
            checkTransactionActive(transaction);
        } else if (transaction != null) {
            throw FbExceptionBuilder
                    .forException(JaybirdErrorCodes.jb_executeImmediateRequiresNoTransactionDetached)
                    .toFlatSQLException();
        }

        final byte[] statementArray = getEncoding().encodeToCharset(statementText);
        synchronized (getSynchronizationObject()) {
            clientLibrary.isc_dsql_execute_immediate(statusVector, handle,
                    transaction != null ? ((JnaTransaction) transaction).getJnaHandle() : new IntByReference(),
                    (short) statementArray.length, statementArray, getConnectionDialect(), null);
            processStatusVector();

            if (!isAttached()) {
                setAttached();
                afterAttachActions();
            }
        }
    } catch (SQLException e) {
        exceptionListenerDispatcher.errorOccurred(e);
        throw e;
    }
}
 
Example 18
/**
 * Create SQLNonTransientException and setting all objects to null
 */
@Test
public void test() {
    SQLNonTransientException e = new SQLNonTransientException(null,
            null, errorCode, null);
    assertTrue(e.getMessage() == null && e.getSQLState() == null
            && e.getCause() == null && e.getErrorCode() == errorCode);
}
 
Example 19
/**
 * Create SQLNonTransientException with message, and SQLState
 */
@Test
public void test3() {
    SQLNonTransientException ex = new SQLNonTransientException(reason, state);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && ex.getCause() == null
            && ex.getErrorCode() == 0);
}
 
Example 20
/**
 * Create SQLNonTransientException with message, SQLState, errorCode, and Throwable
 */
@Test
public void test5() {
    SQLNonTransientException ex =
            new SQLNonTransientException(reason, state, errorCode, t);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && cause.equals(ex.getCause().toString())
            && ex.getErrorCode() == errorCode);
}
 
Example 21
@Test
public void testCreateFor_disabled_invalidValue_invalidOptionValue() throws Exception {
    GeneratedKeysSupport generatedKeysSupport = GeneratedKeysSupportFactory.createFor("DISABLED", dbMetadata);

    expectedException.expect(SQLNonTransientException.class);
    expectedException.expect(allOf(
            fbMessageStartsWith(JaybirdErrorCodes.jb_invalidGeneratedKeysOption),
            sqlStateEquals(SQLStateConstants.SQL_STATE_INVALID_OPTION_IDENTIFIER)));

    generatedKeysSupport.buildQuery(TEST_INSERT_QUERY, 132);
}
 
Example 22
Source Project: Mycat2   Source File: HintDataNodeHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public RouteResultset route(SystemConfig sysConfig, SchemaConfig schema, int sqlType, String realSQL,
		String charset, ServerConnection sc, LayerCachePool cachePool, String hintSQLValue,int hintSqlType, Map hintMap)
				throws SQLNonTransientException {
	
	String stmt = realSQL;
	
	if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("route datanode sql hint from " + stmt);
	}
	
	RouteResultset rrs = new RouteResultset(stmt, sqlType);		
	PhysicalDBNode dataNode = MycatServer.getInstance().getConfig().getDataNodes().get(hintSQLValue);
	if (dataNode != null) {			
		rrs = RouterUtil.routeToSingleNode(rrs, dataNode.getName(), stmt);
	} else {
		String msg = "can't find hint datanode:" + hintSQLValue;
		LOGGER.warn(msg);
		throw new SQLNonTransientException(msg);
	}

	// 处理导入参数初始化
	if(rrs.getSqlType() == ServerParse.LOAD_DATA_INFILE_SQL){
		LOGGER.info("load data use annotation datanode");
		rrs.getNodes()[0].setLoadData(parseLoadDataPram(stmt , charset));
	}
	
	return rrs;
}
 
Example 23
/**
 * Create SQLNonTransientException with message, and SQLState
 */
@Test
public void test3() {
    SQLNonTransientException ex = new SQLNonTransientException(reason, state);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && ex.getCause() == null
            && ex.getErrorCode() == 0);
}
 
Example 24
Source Project: Mycat2   Source File: AbstractRouteStrategy.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 路由之前必要的处理
 * 主要是全局序列号插入,还有子表插入
 */
private boolean beforeRouteProcess(SchemaConfig schema, int sqlType, String origSQL, ServerConnection sc)
		throws SQLNonTransientException {
	
	return RouterUtil.processWithMycatSeq(schema, sqlType, origSQL, sc)
			|| (sqlType == ServerParse.INSERT && RouterUtil.processERChildTable(schema, origSQL, sc))
			|| (sqlType == ServerParse.INSERT && RouterUtil.processInsert(schema, sqlType, origSQL, sc));
}
 
Example 25
/**
 * Create SQLNonTransientException with no-arg constructor
 */
@Test
public void test1() {
    SQLNonTransientException ex = new SQLNonTransientException();
    assertTrue(ex.getMessage() == null
            && ex.getSQLState() == null
            && ex.getCause() == null
            && ex.getErrorCode() == 0);
}
 
Example 26
/**
 * Serialize a SQLNonTransientException and make sure you can read it back properly
 */
@Test
public void test10() throws Exception {
    SQLNonTransientException e =
            new SQLNonTransientException(reason, state, errorCode, t);
    SQLNonTransientException ex1 =
            createSerializedException(e);
    assertTrue(reason.equals(ex1.getMessage())
            && ex1.getSQLState().equals(state)
            && cause.equals(ex1.getCause().toString())
            && ex1.getErrorCode() == errorCode);
}
 
Example 27
Source Project: gemfirexd-oss   Source File: SectDBSynchronizer.java    License: Apache License 2.0 5 votes vote down vote up
protected SqlExceptionHandler checkExceptionType(SQLException sqle) {
  if (sqle != null) {
    if (sqle instanceof SQLNonTransientConnectionException) {
      // will need to connect again
      return SqlExceptionHandler.REFRESH;
    }
    if (sqle instanceof SQLIntegrityConstraintViolationException) {
      // constraint violations can happen in retries, so default action is to
      // IGNORE them; when errorFile is provided then it will be logged to
      // that in XML format in any case
      return SqlExceptionHandler.IGNORE;
    }
    if (sqle instanceof SQLNonTransientException) {
      // if numErrorTries is defined, then retry some number of times else
      // ignore after having logged warning since retry is not likely to help
      return this.numErrorTries > 0 ? SqlExceptionHandler.IGNORE_BREAK_LOOP
          : SqlExceptionHandler.IGNORE;
    }
    if (sqle instanceof SQLTransientException) {
      // skip the remaining batch and retry whole batch again
      return SqlExceptionHandler.IGNORE_BREAK_LOOP;
    }
    if (sqle instanceof BatchUpdateException) {
      return checkExceptionType(sqle.getNextException());
    }
  }
  return null;
}
 
Example 28
Source Project: Mycat2   Source File: ShardingDefaultSpace.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 路由到defaultSpace的性能测试
 */
public void testDefaultSpace() throws SQLNonTransientException {
    SchemaConfig schema = this.getSchema();
    String sql = "insert into offer (member_id, gmt_create) values ('1','2001-09-13 20:20:33')";
    for (int i = 0; i < total; i++) {
        RouteStrategyFactory.getRouteStrategy().route(new SystemConfig(),schema,-1, sql, null, null,cachePool);
    }
}
 
Example 29
/**
 * Create SQLNonTransientException with message, SQLState, and Throwable
 */
@Test
public void test6() {
    SQLNonTransientException ex = new SQLNonTransientException(reason, state, t);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && cause.equals(ex.getCause().toString())
            && ex.getErrorCode() == 0);
}
 
Example 30
Source Project: dble   Source File: RouterUtil.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void routeNoNameTableToSingleNode(RouteResultset rrs, SchemaConfig schema) throws SQLNonTransientException {
    if (schema == null) {
        String db = SchemaUtil.getRandomDb();
        if (db == null) {
            String msg = "No schema is configured, make sure your config is right, sql:" + rrs.getStatement();
            throw new SQLNonTransientException(msg);
        }
        schema = DbleServer.getInstance().getConfig().getSchemas().get(db);
    }
    rrs = RouterUtil.routeToSingleNode(rrs, schema.getMetaDataNode());
    rrs.setFinishedRoute(true);
}