实际上,我想将spring javadoc与我的netbeans IDE集成.Spring网站仅在线提供HTML版本的javadoc,没有下载链接.但Netbeans只接受jar/zip文件或本地文件夹.
我知道我可以自己从泉源建造它,但宁愿不通过工作.
请参阅Spring DataSourceTransactionManager.java中的注释,函数doBegin:
// Switch to manual commit if necessary. This is very expensive in some JDBC drivers,
// so we don't want to do it unnecessarily (for example if we've explicitly
// configured the connection pool to set it already).
if (con.getAutoCommit()) {
txObject.setMustRestoreAutoCommit(true);
if (logger.isDebugEnabled()) {
logger.debug("Switching JDBC Connection [" + con + "] to manual commit");
}
con.setAutoCommit(false);
}
Run Code Online (Sandbox Code Playgroud)
在我正在进行的项目中,未配置自动提交.所以默认情况下是这样.我们使用Spring来管理事务,所有SQL都在@Transactional注释函数中执行.因此,事务是手动提交的.每次事务开始时,db连接都将autocommit设置为false,并在事务退出后将autocommit设置回true.典型的工作流程是(在JDBC级别):
设置autocommit来回昂贵吗?我们应该为性能原因配置数据源连接池autocommit = false吗?跳过第2步和第6步.
我正在使用rabbitmq java client 2.4.1 最新版本。
TCP 连接丢失后,仍然通过此连接调用通道上的方法,将抛出 AlreadyClosedException。
这是一个错误吗?我期待 IOException,但我得到了 AlreadyClosedException,而 AlreadyClosedException 是 RuntimeException。
如果不是,为什么所有其他错误都会导致 IOException。
@Test
public void testConnectionLost() throws IOException{
ConnectionFactory factory = new ConnectionFactory();
factory.setRequestedHeartbeat(60);
factory.setHost("<your rabbitmq host>");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
connection.close();
try {
channel.queueDeclare("queueName", false, false, false, null);
Assert.fail("Exception expected.");
}catch (IOException e) {
//it will NOT reach here.
//Inner exception should be AlreadyClosedException
System.out.println(e);
}catch (AlreadyClosedException e) {
// it will reach here.
System.out.println(e);
//this is strange!
//I expected IOException …Run Code Online (Sandbox Code Playgroud)