本文整理汇总了Java中com.mysql.jdbc.PacketTooBigException类的典型用法代码示例。如果您正苦于以下问题:Java PacketTooBigException类的具体用法?Java PacketTooBigException怎么用?Java PacketTooBigException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PacketTooBigException类属于com.mysql.jdbc包,在下文中一共展示了PacketTooBigException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExceptionStrategyWithPacketTooBigExceptionPropSetY
import com.mysql.jdbc.PacketTooBigException; //导入依赖的package包/类
/**
* Property value has priority
*/
@Test public void testExceptionStrategyWithPacketTooBigExceptionPropSetY() {
System.setProperty( DatabaseLogExceptionFactory.KETTLE_GLOBAL_PROP_NAME, PROPERTY_VALUE_TRUE );
DatabaseMeta databaseMeta = mock( DatabaseMeta.class );
DatabaseInterface databaseInterface = new MySQLDatabaseMeta();
PacketTooBigException e = new PacketTooBigException();
when( logTable.getDatabaseMeta() ).thenReturn( databaseMeta );
when( databaseMeta.getDatabaseInterface() ).thenReturn( databaseInterface );
LogExceptionBehaviourInterface
exceptionStrategy =
DatabaseLogExceptionFactory.getExceptionStrategy( logTable, new KettleDatabaseException( e ) );
String strategyName = exceptionStrategy.getClass().getName();
assertEquals( THROWABLE, strategyName );
}
示例2: testPacketTooLargeException
import com.mysql.jdbc.PacketTooBigException; //导入依赖的package包/类
/**
* Tests that PacketTooLargeException doesn't clober the connection.
*
* @throws Exception
* if the test fails.
*/
public void testPacketTooLargeException() throws Exception {
final ConnectionEventListener conListener = new ConnectionListener();
PooledConnection pc = null;
pc = this.cpds.getPooledConnection();
pc.addConnectionEventListener(conListener);
createTable("testPacketTooLarge", "(field1 LONGBLOB)");
Connection connFromPool = pc.getConnection();
PreparedStatement pstmtFromPool = ((ConnectionWrapper) connFromPool).clientPrepare("INSERT INTO testPacketTooLarge VALUES (?)");
this.rs = this.stmt.executeQuery("SHOW VARIABLES LIKE 'max_allowed_packet'");
this.rs.next();
int maxAllowedPacket = this.rs.getInt(2);
int numChars = (int) (maxAllowedPacket * 1.2);
pstmtFromPool.setBinaryStream(1, new BufferedInputStream(new FileInputStream(newTempBinaryFile("testPacketTooLargeException", numChars))), numChars);
try {
pstmtFromPool.executeUpdate();
fail("Expecting PacketTooLargeException");
} catch (PacketTooBigException ptbe) {
// We're expecting this one...
}
// This should still work okay, even though the last query on the same connection didn't...
this.rs = connFromPool.createStatement().executeQuery("SELECT 1");
assertTrue(this.connectionErrorEventCount == 0);
assertTrue(this.closeEventCount == 0);
}
示例3: testPacketTooLargeException
import com.mysql.jdbc.PacketTooBigException; //导入依赖的package包/类
/**
* Tests that PacketTooLargeException doesn't clober the connection.
*
* @throws Exception
* if the test fails.
*/
public void testPacketTooLargeException() throws Exception {
final ConnectionEventListener conListener = new ConnectionListener();
PooledConnection pc = null;
pc = this.cpds.getPooledConnection();
pc.addConnectionEventListener(conListener);
createTable("testPacketTooLarge", "(field1 LONGBLOB)");
Connection connFromPool = pc.getConnection();
PreparedStatement pstmtFromPool = ((ConnectionWrapper) connFromPool).clientPrepare("INSERT INTO testPacketTooLarge VALUES (?)");
this.rs = this.stmt.executeQuery("SHOW VARIABLES LIKE 'max_allowed_packet'");
this.rs.next();
int maxAllowedPacket = this.rs.getInt(2);
int numChars = (int) (maxAllowedPacket * 1.2);
pstmtFromPool.setBinaryStream(1, new BufferedInputStream(new FileInputStream(newTempBinaryFile("testPacketTooLargeException", numChars))), numChars);
try {
pstmtFromPool.executeUpdate();
fail("Expecting PacketTooLargeException");
} catch (PacketTooBigException ptbe) {
// We're expecting this one...
}
// This should still work okay, even though the last query on the same connection didn't...
connFromPool.createStatement().executeQuery("SELECT 1");
assertTrue(this.connectionErrorEventCount == 0);
assertTrue(this.closeEventCount == 0);
}
示例4: testExceptionStrategyWithPacketTooBigException
import com.mysql.jdbc.PacketTooBigException; //导入依赖的package包/类
/**
* PDI-5153
* Test that in case of PacketTooBigException exception there will be no stack trace in log
*/
@Test public void testExceptionStrategyWithPacketTooBigException() {
DatabaseMeta databaseMeta = mock( DatabaseMeta.class );
DatabaseInterface databaseInterface = new MySQLDatabaseMeta();
PacketTooBigException e = new PacketTooBigException();
when( logTable.getDatabaseMeta() ).thenReturn( databaseMeta );
when( databaseMeta.getDatabaseInterface() ).thenReturn( databaseInterface );
LogExceptionBehaviourInterface
exceptionStrategy =
DatabaseLogExceptionFactory.getExceptionStrategy( logTable, new KettleDatabaseException( e ) );
String strategyName = exceptionStrategy.getClass().getName();
assertEquals( SUPPRESSABLE_WITH_SHORT_MESSAGE, strategyName );
}
示例5: killJob
import com.mysql.jdbc.PacketTooBigException; //导入依赖的package包/类
/**
* 终止任务过程
*/
public boolean killJob(Record record) {
final Queue<Record> recordQueue = new LinkedBlockingQueue<Record>();
//单一任务
if (JobType.SINGLETON.getCode().equals(record.getJobType())) {
recordQueue.add(record);
} else if (JobType.FLOW.getCode().equals(record.getJobType())) {
//流程任务
recordQueue.addAll(recordService.getRunningFlowJob(record.getRecordId()));
}
final List<Boolean> result = new ArrayList<Boolean>(0);
final Semaphore semaphore = new Semaphore(recordQueue.size());
ExecutorService exec = Executors.newCachedThreadPool();
for (final Record cord : recordQueue) {
Runnable task = new Runnable() {
@Override
public void run() {
JobVo job = null;
try {
semaphore.acquire();
//临时的改成停止中...
cord.setStatus(RunStatus.STOPPING.getStatus());//停止中
cord.setSuccess(ResultStatus.KILLED.getStatus());//被杀.
recordService.merge(cord);
job = jobService.getJobVoById(cord.getJobId());
//向远程机器发送kill指令
opencronCaller.call(Request.request(job.getIp(), job.getPort(), Action.KILL, job.getPassword()).putParam("pid", cord.getPid()), job.getAgent());
cord.setStatus(RunStatus.STOPED.getStatus());
cord.setEndTime(new Date());
recordService.merge(cord);
loggerInfo("killed successful :jobName:{} at ip:{},port:{},pid:{}", job, cord.getPid());
} catch (Exception e) {
if (e instanceof PacketTooBigException) {
noticeService.notice(job, PACKETTOOBIG_ERROR);
loggerError("killed error:jobName:%s at ip:%s,port:%d,pid:%s", job, cord.getPid() + " failed info: " + PACKETTOOBIG_ERROR, e);
}
noticeService.notice(job, null);
loggerError("killed error:jobName:%s at ip:%s,port:%d,pid:%s", job, cord.getPid() + " failed info: " + e.getMessage(), e);
logger.error("[opencron] job rumModel with SAMETIME error:{}", e.getMessage());
result.add(false);
}
semaphore.release();
}
};
exec.submit(task);
}
exec.shutdown();
while (true) {
if (exec.isTerminated()) {
logger.info("[opencron] SAMETIMEjob done!");
return !result.contains(false);
}
}
}
示例6: testPacketTooLargeException
import com.mysql.jdbc.PacketTooBigException; //导入依赖的package包/类
/**
* Tests that PacketTooLargeException doesn't clober the connection.
*
* @throws Exception
* if the test fails.
*/
public void testPacketTooLargeException() throws Exception {
final ConnectionEventListener conListener = new ConnectionListener();
PooledConnection pc = null;
pc = this.cpds.getPooledConnection();
pc.addConnectionEventListener(conListener);
createTable("testPacketTooLarge", "(field1 LONGBLOB)");
Connection connFromPool = pc.getConnection();
PreparedStatement pstmtFromPool = ((ConnectionWrapper) connFromPool)
.clientPrepare("INSERT INTO testPacketTooLarge VALUES (?)");
this.rs = this.stmt
.executeQuery("SHOW VARIABLES LIKE 'max_allowed_packet'");
this.rs.next();
int maxAllowedPacket = this.rs.getInt(2);
int numChars = (int) (maxAllowedPacket * 1.2);
pstmtFromPool.setBinaryStream(
1,
new BufferedInputStream(new FileInputStream(newTempBinaryFile(
"testPacketTooLargeException", numChars))), numChars);
try {
pstmtFromPool.executeUpdate();
fail("Expecting PacketTooLargeException");
} catch (PacketTooBigException ptbe) {
// We're expecting this one...
}
// This should still work okay, even though the last query on the
// same
// connection didn't...
connFromPool.createStatement().executeQuery("SELECT 1");
assertTrue(this.connectionErrorEventCount == 0);
assertTrue(this.closeEventCount == 0);
}