Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
33633d37
提交
33633d37
authored
6月 02, 2011
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The built-in connection pool is now a bit faster.
上级
f805561a
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
12 行增加
和
30 行删除
+12
-30
JdbcXAConnection.java
h2/src/main/org/h2/jdbcx/JdbcXAConnection.java
+12
-30
没有找到文件。
h2/src/main/org/h2/jdbcx/JdbcXAConnection.java
浏览文件 @
33633d37
...
@@ -18,13 +18,11 @@ import javax.transaction.xa.XAException;
...
@@ -18,13 +18,11 @@ import javax.transaction.xa.XAException;
import
javax.transaction.xa.XAResource
;
import
javax.transaction.xa.XAResource
;
import
javax.transaction.xa.Xid
;
import
javax.transaction.xa.Xid
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.ErrorCode
;
import
org.h2.constant.SysProperties
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.jdbc.JdbcConnection
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.New
;
import
org.h2.util.New
;
import
org.h2.message.DbException
;
import
org.h2.message.DbException
;
import
org.h2.message.Trace
;
import
org.h2.message.TraceObject
;
import
org.h2.message.TraceObject
;
//## Java 1.6 begin ##
//## Java 1.6 begin ##
...
@@ -40,11 +38,11 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
...
@@ -40,11 +38,11 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
private
JdbcDataSourceFactory
factory
;
private
JdbcDataSourceFactory
factory
;
//
T
his connection is kept open as long as the XAConnection is alive
//
t
his connection is kept open as long as the XAConnection is alive
private
JdbcConnection
physicalConn
;
private
JdbcConnection
physicalConn
;
//
T
his connection is replaced whenever getConnection is called
//
t
his connection is replaced whenever getConnection is called
private
volatile
PooledJdbc
Connection
handleConn
;
private
volatile
Connection
handleConn
;
private
ArrayList
<
ConnectionEventListener
>
listeners
=
New
.
arrayList
();
private
ArrayList
<
ConnectionEventListener
>
listeners
=
New
.
arrayList
();
private
Xid
currentTransaction
;
private
Xid
currentTransaction
;
...
@@ -76,7 +74,7 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
...
@@ -76,7 +74,7 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
*/
*/
public
void
close
()
throws
SQLException
{
public
void
close
()
throws
SQLException
{
debugCodeCall
(
"close"
);
debugCodeCall
(
"close"
);
PooledJdbc
Connection
lastHandle
=
handleConn
;
Connection
lastHandle
=
handleConn
;
if
(
lastHandle
!=
null
)
{
if
(
lastHandle
!=
null
)
{
listeners
.
clear
();
listeners
.
clear
();
lastHandle
.
close
();
lastHandle
.
close
();
...
@@ -99,10 +97,12 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
...
@@ -99,10 +97,12 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
*/
*/
public
Connection
getConnection
()
throws
SQLException
{
public
Connection
getConnection
()
throws
SQLException
{
debugCodeCall
(
"getConnection"
);
debugCodeCall
(
"getConnection"
);
PooledJdbc
Connection
lastHandle
=
handleConn
;
Connection
lastHandle
=
handleConn
;
if
(
lastHandle
!=
null
)
{
if
(
lastHandle
!=
null
)
{
lastHandle
.
close
();
lastHandle
.
close
();
}
}
// this will ensure the rollback command is cached
physicalConn
.
rollback
();
handleConn
=
new
PooledJdbcConnection
(
physicalConn
);
handleConn
=
new
PooledJdbcConnection
(
physicalConn
);
return
handleConn
;
return
handleConn
;
}
}
...
@@ -132,8 +132,11 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
...
@@ -132,8 +132,11 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
*/
*/
void
closedHandle
()
{
void
closedHandle
()
{
debugCode
(
"closedHandle();"
);
debugCode
(
"closedHandle();"
);
for
(
ConnectionEventListener
listener
:
New
.
arrayList
(
listeners
))
{
ConnectionEvent
event
=
new
ConnectionEvent
(
this
);
ConnectionEvent
event
=
new
ConnectionEvent
(
this
);
// go backward so that a listener can remove itself
// (otherwise we need to clone the list)
for
(
int
i
=
listeners
.
size
()
-
1
;
i
>=
0
;
i
--)
{
ConnectionEventListener
listener
=
listeners
.
get
(
i
);
listener
.
connectionClosed
(
event
);
listener
.
connectionClosed
(
event
);
}
}
handleConn
=
null
;
handleConn
=
null
;
...
@@ -436,9 +439,6 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
...
@@ -436,9 +439,6 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
public
PooledJdbcConnection
(
JdbcConnection
conn
)
{
public
PooledJdbcConnection
(
JdbcConnection
conn
)
{
super
(
conn
);
super
(
conn
);
if
(
SysProperties
.
runFinalize
)
{
openStackTrace
=
new
Exception
(
"Stack Trace"
);
}
}
}
public
synchronized
void
close
()
throws
SQLException
{
public
synchronized
void
close
()
throws
SQLException
{
...
@@ -461,24 +461,6 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
...
@@ -461,24 +461,6 @@ public class JdbcXAConnection extends TraceObject implements XAConnection, XARes
super
.
checkClosed
(
write
);
super
.
checkClosed
(
write
);
}
}
protected
void
finalize
()
{
// don't call super.finalize because
// this should print its own stack trace,
// and would close the connection
if
(!
SysProperties
.
runFinalize
)
{
return
;
}
Trace
trace
=
getTrace
();
try
{
if
(!
isClosed
())
{
trace
.
error
(
openStackTrace
,
"pooled connection not closed"
);
JdbcXAConnection
.
this
.
close
();
}
}
catch
(
SQLException
e
)
{
trace
.
debug
(
e
,
"finalize"
);
}
}
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论