本文整理汇总了Java中com.alibaba.cobar.server.ServerConnection.setTxIsolation方法的典型用法代码示例。如果您正苦于以下问题:Java ServerConnection.setTxIsolation方法的具体用法?Java ServerConnection.setTxIsolation怎么用?Java ServerConnection.setTxIsolation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.cobar.server.ServerConnection
的用法示例。
在下文中一共展示了ServerConnection.setTxIsolation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void handle(String stmt, ServerConnection c, int offset) {
int rs = ServerParseSet.parse(stmt, offset);
switch (rs & 0xff) {
case AUTOCOMMIT_ON:
if (!c.isAutocommit()) {
c.setAutocommit(true);
}
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
case AUTOCOMMIT_OFF: {
if (c.isAutocommit()) {
c.setAutocommit(false);
}
c.write(c.writeToBuffer(AC_OFF, c.allocate()));
break;
}
case TX_READ_UNCOMMITTED: {
c.setTxIsolation(Isolations.READ_UNCOMMITTED.getCode());
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case TX_READ_COMMITTED: {
c.setTxIsolation(Isolations.READ_COMMITTED.getCode());
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case TX_REPEATED_READ: {
c.setTxIsolation(Isolations.REPEATED_READ.getCode());
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case TX_SERIALIZABLE: {
c.setTxIsolation(Isolations.SERIALIZABLE.getCode());
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case NAMES:
String charset = stmt.substring(rs >>> 8).trim();
if (c.setCharset(charset)) {
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
} else {
c.writeErrMessage(ErrorCode.ER_UNKNOWN_CHARACTER_SET, "Unknown charset '" + charset + "'");
}
break;
case CHARACTER_SET_CLIENT:
case CHARACTER_SET_CONNECTION:
case CHARACTER_SET_RESULTS:
CharacterSet.response(stmt, c, rs);
break;
case SQL_MODE:
SqlMode.response(stmt, c, rs);
break;
case TX_POLICY_1:
c.setTrxPolicy(ITransactionPolicy.TDDL);
break;
// case TX_POLICY_2:
// c.setTrxPolicy(new Cobar());
// c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
// break;
case TX_POLICY_3:
c.setTrxPolicy(ITransactionPolicy.ALLOW_READ_CROSS_DB);
break;
// case TX_POLICY_4:
// c.setTrxPolicy(new Corona());
// c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
// break;
case TX_POLICY_5:
c.setTrxPolicy(ITransactionPolicy.FREE);
break;
case AT_VAR:
c.execute(stmt, ServerParse.SET);
default:
StringBuilder s = new StringBuilder();
logger.warn(s.append(stmt).append(" is not executed").toString());
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
}
}
示例2: handle
import com.alibaba.cobar.server.ServerConnection; //导入方法依赖的package包/类
public static void handle(String stmt, ServerConnection c, int offset) {
int rs = ServerParseSet.parse(stmt, offset);
switch (rs & 0xff) {
case AUTOCOMMIT_ON:
if (c.isAutocommit()) {
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
} else {
c.commit();
c.setAutocommit(true);
}
break;
case AUTOCOMMIT_OFF: {
if (c.isAutocommit()) {
c.setAutocommit(false);
}
c.write(c.writeToBuffer(AC_OFF, c.allocate()));
break;
}
case TX_READ_UNCOMMITTED: {
c.setTxIsolation(Isolations.READ_UNCOMMITTED);
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case TX_READ_COMMITTED: {
c.setTxIsolation(Isolations.READ_COMMITTED);
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case TX_REPEATED_READ: {
c.setTxIsolation(Isolations.REPEATED_READ);
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case TX_SERIALIZABLE: {
c.setTxIsolation(Isolations.SERIALIZABLE);
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
break;
}
case NAMES:
String charset = stmt.substring(rs >>> 8).trim();
if (c.setCharset(charset)) {
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
} else {
c.writeErrMessage(ErrorCode.ER_UNKNOWN_CHARACTER_SET, "Unknown charset '" + charset + "'");
}
break;
case CHARACTER_SET_CLIENT:
case CHARACTER_SET_CONNECTION:
case CHARACTER_SET_RESULTS:
CharacterSet.response(stmt, c, rs);
break;
default:
StringBuilder s = new StringBuilder();
logger.warn(s.append(c).append(stmt).append(" is not executed").toString());
c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
}
}