本文整理匯總了Java中java.sql.SQLNonTransientException類的典型用法代碼示例。如果您正苦於以下問題:Java SQLNonTransientException類的具體用法?Java SQLNonTransientException怎麽用?Java SQLNonTransientException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SQLNonTransientException類屬於java.sql包,在下文中一共展示了SQLNonTransientException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: confirmChildColumnNotUpdated
import java.sql.SQLNonTransientException; //導入依賴的package包/類
/**
* confirmChildColumnNotUpdated
*
* @throws SQLNonTransientException
*/
private void confirmChildColumnNotUpdated(SQLUpdateStatement update, SchemaConfig schema, String tableName) throws SQLNonTransientException {
if (schema.getFkErRelations() == null) {
return;
}
List<SQLUpdateSetItem> updateSetItem = update.getItems();
if (updateSetItem != null && updateSetItem.size() > 0) {
for (SQLUpdateSetItem item : updateSetItem) {
String column = StringUtil.removeBackQuote(item.getColumn().toString().toUpperCase());
if (isJoinColumn(column, schema, tableName)) {
String msg = "child relevant column can't be updated " + tableName + "->" + column;
LOGGER.info(msg);
throw new SQLNonTransientException(msg);
}
}
}
}
示例2: statementParse
import java.sql.SQLNonTransientException; //導入依賴的package包/類
@Override
public void statementParse(SchemaConfig schema, RouteResultset rrs, SQLStatement stmt) throws SQLNonTransientException {
MySqlCreateTableStatement createStmt = (MySqlCreateTableStatement)stmt;
if(createStmt.getQuery() != null) {
String msg = "create table from other table not supported :" + stmt;
LOGGER.warn(msg);
throw new SQLNonTransientException(msg);
}
String tableName = StringUtil.removeBackquote(createStmt.getTableSource().toString().toUpperCase());
if(schema.getTables().containsKey(tableName)) {
TableConfig tableConfig = schema.getTables().get(tableName);
AbstractPartitionAlgorithm algorithm = tableConfig.getRule().getRuleAlgorithm();
if(algorithm instanceof SlotFunction){
SQLColumnDefinition column = new SQLColumnDefinition();
column.setDataType(new SQLCharacterDataType("int"));
column.setName(new SQLIdentifierExpr("_slot"));
column.setComment(new SQLCharExpr("自動遷移算法slot,禁止修改"));
((SQLCreateTableStatement)stmt).getTableElementList().add(column);
String sql = createStmt.toString();
rrs.setStatement(sql);
ctx.setSql(sql);
}
}
ctx.addTable(tableName);
}
示例3: isRoutMultiNode
import java.sql.SQLNonTransientException; //導入依賴的package包/類
private boolean isRoutMultiNode(SchemaConfig schema, RouteResultset rrs)
{
if(rrs.getNodes()!=null&&rrs.getNodes().length>1)
{
return true;
}
LayerCachePool tableId2DataNodeCache = (LayerCachePool) MycatServer.getInstance().getCacheService().getCachePool("TableID2DataNodeCache");
try
{
tryRoute(schema, rrs, tableId2DataNodeCache);
if(rrs.getNodes()!=null&&rrs.getNodes().length>1)
{
return true;
}
} catch (SQLNonTransientException e)
{
throw new RuntimeException(e);
}
return false;
}
示例4: setLimitIFChange
import java.sql.SQLNonTransientException; //導入依賴的package包/類
protected void setLimitIFChange(SQLStatement stmt, RouteResultset rrs, SchemaConfig schema, SQLBinaryOpExpr one, int firstrownum, int lastrownum)
{
rrs.setLimitStart(firstrownum);
rrs.setLimitSize(lastrownum - firstrownum);
LayerCachePool tableId2DataNodeCache = (LayerCachePool) MycatServer.getInstance().getCacheService().getCachePool("TableID2DataNodeCache");
try
{
tryRoute(schema, rrs, tableId2DataNodeCache);
} catch (SQLNonTransientException e)
{
throw new RuntimeException(e);
}
if (isNeedChangeLimit(rrs))
{
one.setRight(new SQLIntegerExpr(0));
String curentDbType ="db2".equalsIgnoreCase(this.getCurentDbType())?"oracle":getCurentDbType();
String sql = SQLUtils.toSQLString(stmt, curentDbType);;
rrs.changeNodeSqlAfterAddLimit(schema,getCurentDbType(), sql,0,lastrownum, false);
//設置改寫後的sql
getCtx().setSql(sql);
}
}
示例5: routerForJoinTable
import java.sql.SQLNonTransientException; //導入依賴的package包/類
private static void routerForJoinTable(RouteResultset rrs, TableConfig tableConfig, Map<String, Set<ColumnRoutePair>> columnsMap, String joinKey) throws SQLNonTransientException {
//childTable (if it's ER JOIN of select)must find root table,remove childTable, only left root table
Set<ColumnRoutePair> joinKeyValue = columnsMap.get(joinKey);
Set<String> dataNodeSet = ruleByJoinValueCalculate(rrs, tableConfig, joinKeyValue);
if (dataNodeSet.isEmpty()) {
throw new SQLNonTransientException(
"parent key can't find any valid datanode ");
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("found partion nodes (using parent partion rule directly) for child table to update " +
Arrays.toString(dataNodeSet.toArray()) + " sql :" + rrs.getStatement());
}
if (dataNodeSet.size() > 1) {
routeToMultiNode(rrs.isCacheAble(), rrs, dataNodeSet);
rrs.setFinishedRoute(true);
return;
} else {
rrs.setCacheAble(true);
routeToSingleNode(rrs, dataNodeSet.iterator().next());
return;
}
}
示例6: visitorParse
import java.sql.SQLNonTransientException; //導入依賴的package包/類
@Override
public SchemaConfig visitorParse(SchemaConfig schema, RouteResultset rrs, SQLStatement stmt, ServerSchemaStatVisitor visitor, ServerConnection sc)
throws SQLException {
SQLDropTableStatement dropTable = (SQLDropTableStatement) stmt;
if (dropTable.getTableSources().size() > 1) {
String msg = "dropping multi-tables is not supported, sql:" + stmt;
throw new SQLNonTransientException(msg);
}
String schemaName = schema == null ? null : schema.getName();
SchemaInfo schemaInfo = SchemaUtil.getSchemaInfo(sc.getUser(), schemaName, dropTable.getTableSources().get(0));
String statement = RouterUtil.removeSchema(rrs.getStatement(), schemaInfo.getSchema());
rrs.setStatement(statement);
if (RouterUtil.isNoSharding(schemaInfo.getSchemaConfig(), schemaInfo.getTable())) {
RouterUtil.routeToSingleDDLNode(schemaInfo, rrs);
return schemaInfo.getSchemaConfig();
}
RouterUtil.routeToDDLNode(schemaInfo, rrs);
return schemaInfo.getSchemaConfig();
}
示例7: route
import java.sql.SQLNonTransientException; //導入依賴的package包/類
/**
* 從全局的schema列表中查詢指定的schema是否存在, 如果存在則替換connection屬性中原有的schema,
* 如果不存在,則throws SQLNonTransientException,表示指定的schema 不存在
*
* @param sysConfig
* @param schema
* @param sqlType
* @param realSQL
* @param charset
* @param info
* @param cachePool
* @param hintSQLValue
* @return
* @throws SQLNonTransientException
*/
@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 {
// sc.setEngineCtx ctx
String cateletClass = hintSQLValue;
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("load catelet class:" + hintSQLValue + " to run sql "
+ realSQL);
}
try {
Catlet catlet = (Catlet) MycatServer.getInstance()
.getCatletClassLoader().getInstanceofClass(cateletClass);
catlet.route(sysConfig, schema, sqlType, realSQL,charset, sc, cachePool);
catlet.processSQL(realSQL, new EngineCtx(sc.getSession2()));
} catch (Exception e) {
LOGGER.warn("catlet error "+e);
throw new SQLNonTransientException(e);
}
return null;
}
示例8: routeEndExecuteSQL
import java.sql.SQLNonTransientException; //導入依賴的package包/類
private void routeEndExecuteSQL(String sql, int type, SchemaConfig schema) {
RouteResultset rrs;
try {
rrs = DbleServer.getInstance().getRouterService().route(schema, type, sql, this);
if (rrs == null) {
return;
}
if (rrs.getSqlType() == ServerParse.DDL) {
addTableMetaLock(rrs);
if (DbleServer.getInstance().getTmManager().getCatalogs().get(rrs.getSchema()).getView(rrs.getTable()) != null) {
DbleServer.getInstance().getTmManager().removeMetaLock(rrs.getSchema(), rrs.getTable());
String msg = "Table '" + rrs.getTable() + "' already exists as a view";
LOGGER.info(msg);
throw new SQLNonTransientException(msg);
}
}
} catch (Exception e) {
executeException(e, sql);
return;
}
session.execute(rrs);
}
示例9: genDuplicate
import java.sql.SQLNonTransientException; //導入依賴的package包/類
private void genDuplicate(boolean isGlobalCheck, StringBuilder sb, List<SQLExpr> dku) throws SQLNonTransientException {
boolean flag = false;
sb.append(" on duplicate key update ");
for (int i = 0; i < dku.size(); i++) {
SQLExpr exp = dku.get(i);
if (!(exp instanceof SQLBinaryOpExpr)) {
String msg = "not supported! on duplicate key update exp is " + exp.getClass();
LOGGER.info(msg);
throw new SQLNonTransientException(msg);
}
SQLBinaryOpExpr binaryOpExpr = (SQLBinaryOpExpr) exp;
if (isGlobalCheck && !flag && GlobalTableUtil.GLOBAL_TABLE_CHECK_COLUMN.equals(binaryOpExpr.getLeft().toString())) {
flag = true;
onDuplicateGlobalColumn(sb);
} else {
sb.append(binaryOpExpr.toString());
}
if (i < dku.size() - 1) {
sb.append(",");
}
}
if (isGlobalCheck && !flag) {
sb.append(",");
onDuplicateGlobalColumn(sb);
}
}
示例10: testRange
import java.sql.SQLNonTransientException; //導入依賴的package包/類
@Test
public void testRange() throws SQLNonTransientException {
String sql = "select * from offer1 where col_date between '2014-01-01 00:00:00' and '2014-01-03 23:59:59' order by id desc limit 100";
SchemaConfig schema = schemaMap.get("TESTDB");
RouteResultset rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,
null, cachePool);
junit.framework.Assert.assertEquals(6, rrs.getNodes().length);
sql = "select * from offer1 where col_date between '2014-01-01 00:00:00' and '2014-01-04 00:00:59' order by id desc limit 100";
rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,
null, cachePool);
junit.framework.Assert.assertEquals(12, rrs.getNodes().length);
sql = "select * from offer1 where col_date between '2014-01-04 00:00:00' and '2014-01-06 23:59:59' order by id desc limit 100";
rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,
null, cachePool);
junit.framework.Assert.assertEquals(6, rrs.getNodes().length);
}
示例11: testRange
import java.sql.SQLNonTransientException; //導入依賴的package包/類
@Test
public void testRange() throws SQLNonTransientException {
String sql = "select * from offer where id between 2000000 and 4000001 order by id desc limit 100";
SchemaConfig schema = schemaMap.get("TESTDB");
RouteResultset rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,
null, cachePool);
Assert.assertEquals(10, rrs.getNodes().length);
sql = "select * from offer where id between 9 and 2000 order by id desc limit 100";
rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,
null, cachePool);
Assert.assertEquals(5, rrs.getNodes().length);
sql = "select * from offer where id between 4000001 and 6005001 order by id desc limit 100";
rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,
null, cachePool);
Assert.assertEquals(8, rrs.getNodes().length);
}
示例12: testHaving
import java.sql.SQLNonTransientException; //導入依賴的package包/類
@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);
}
示例13: visitorParse
import java.sql.SQLNonTransientException; //導入依賴的package包/類
@Override
public SchemaConfig visitorParse(SchemaConfig schema, RouteResultset rrs, SQLStatement stmt, ServerSchemaStatVisitor visitor, ServerConnection sc)
throws SQLException {
stmt.accept(visitor);
if (visitor.getNotSupportMsg() != null) {
throw new SQLNonTransientException(visitor.getNotSupportMsg());
}
List<List<Condition>> mergedConditionList = new ArrayList<>();
if (visitor.hasOrCondition()) {
mergedConditionList = visitor.splitConditions();
} else {
mergedConditionList.add(visitor.getConditions());
}
Map<String, String> tableAliasMap = getTableAliasMap(visitor.getAliasMap());
ctx.setRouteCalculateUnits(this.buildRouteCalculateUnits(tableAliasMap, mergedConditionList));
return schema;
}
示例14: test12
import java.sql.SQLNonTransientException; //導入依賴的package包/類
/**
* 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();
}
}
示例15: route
import java.sql.SQLNonTransientException; //導入依賴的package包/類
@Override
public RouteResultset route(SchemaConfig schema, int sqlType, String realSQL, ServerConnection sc,
LayerCachePool cachePool, String hintSQLValue, int hintSqlType, Map hintMap)
throws SQLNonTransientException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("route datanode sql hint from " + realSQL);
}
RouteResultset rrs = new RouteResultset(realSQL, sqlType);
PhysicalDBNode dataNode = DbleServer.getInstance().getConfig().getDataNodes().get(hintSQLValue);
if (dataNode != null) {
rrs = RouterUtil.routeToSingleNode(rrs, dataNode.getName());
} else {
String msg = "can't find hint datanode:" + hintSQLValue;
LOGGER.info(msg);
throw new SQLNonTransientException(msg);
}
return rrs;
}