Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f5339ed9
提交
f5339ed9
authored
5月 02, 2008
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
--no commit message
上级
4715ebcd
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
1517 行增加
和
1300 行删除
+1517
-1300
_docs_en.utf8.txt
h2/src/docsrc/text/_docs_en.utf8.txt
+364
-382
_docs_ja.utf8.txt
h2/src/docsrc/text/_docs_ja.utf8.txt
+393
-384
_docs_en.properties
h2/src/docsrc/textbase/_docs_en.properties
+362
-368
Database.java
h2/src/main/org/h2/engine/Database.java
+322
-102
DatabaseCloser.java
h2/src/main/org/h2/engine/DatabaseCloser.java
+6
-1
Engine.java
h2/src/main/org/h2/engine/Engine.java
+13
-1
FunctionAlias.java
h2/src/main/org/h2/engine/FunctionAlias.java
+7
-5
UserAggregate.java
h2/src/main/org/h2/engine/UserAggregate.java
+2
-1
JavaFunction.java
h2/src/main/org/h2/expression/JavaFunction.java
+1
-1
TriggerObject.java
h2/src/main/org/h2/schema/TriggerObject.java
+2
-1
RunScript.java
h2/src/main/org/h2/tools/RunScript.java
+1
-5
Shell.java
h2/src/main/org/h2/tools/Shell.java
+1
-6
ClassUtils.java
h2/src/main/org/h2/util/ClassUtils.java
+8
-2
JdbcDriverUtils.java
h2/src/main/org/h2/util/JdbcDriverUtils.java
+4
-2
JdbcUtils.java
h2/src/main/org/h2/util/JdbcUtils.java
+30
-39
Build.java
h2/src/tools/org/h2/build/Build.java
+1
-0
没有找到文件。
h2/src/docsrc/text/_docs_en.utf8.txt
浏览文件 @
f5339ed9
差异被折叠。
点击展开。
h2/src/docsrc/text/_docs_ja.utf8.txt
浏览文件 @
f5339ed9
差异被折叠。
点击展开。
h2/src/docsrc/textbase/_docs_en.properties
浏览文件 @
f5339ed9
差异被折叠。
点击展开。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
f5339ed9
差异被折叠。
点击展开。
h2/src/main/org/h2/engine/DatabaseCloser.java
浏览文件 @
f5339ed9
...
...
@@ -10,7 +10,8 @@ import java.lang.ref.WeakReference;
/**
* This class is responsible to close a database if the application did not
* close a connection.
* close a connection. A database closer object only exists if there is no user
* connected to the database.
*/
public
class
DatabaseCloser
extends
Thread
{
...
...
@@ -25,6 +26,10 @@ public class DatabaseCloser extends Thread {
this
.
shutdownHook
=
shutdownHook
;
}
/**
* Stop and disable the database closer. This method is called after the
* database has been closed, or after a session has been created.
*/
public
void
reset
()
{
synchronized
(
this
)
{
databaseRef
=
null
;
...
...
h2/src/main/org/h2/engine/Engine.java
浏览文件 @
f5339ed9
...
...
@@ -94,11 +94,17 @@ public class Engine {
throw
Message
.
getSQLException
(
ErrorCode
.
WRONG_USER_OR_PASSWORD
);
}
checkClustering
(
ci
,
database
);
Session
session
=
database
.
create
User
Session
(
user
);
Session
session
=
database
.
createSession
(
user
);
return
session
;
}
}
/**
* Open a database connection with the given connection information.
*
* @param ci the connection information
* @return the session
*/
public
Session
getSession
(
ConnectionInfo
ci
)
throws
SQLException
{
try
{
Session
session
=
openSession
(
ci
);
...
...
@@ -171,6 +177,12 @@ public class Engine {
}
}
/**
* Called after a database has been closed, to remove the object from the
* list of open databases.
*
* @param name the database name
*/
public
void
close
(
String
name
)
{
databases
.
remove
(
name
);
}
...
...
h2/src/main/org/h2/engine/FunctionAlias.java
浏览文件 @
f5339ed9
...
...
@@ -17,6 +17,7 @@ import org.h2.expression.Expression;
import
org.h2.message.Message
;
import
org.h2.message.Trace
;
import
org.h2.table.Table
;
import
org.h2.util.ClassUtils
;
import
org.h2.value.DataType
;
import
org.h2.value.Value
;
import
org.h2.value.ValueNull
;
...
...
@@ -57,7 +58,7 @@ public class FunctionAlias extends DbObjectBase {
if
(
javaMethod
!=
null
)
{
return
;
}
Class
javaClass
=
database
.
loadUserClass
(
className
);
Class
javaClass
=
ClassUtils
.
loadUserClass
(
className
);
Method
[]
methods
=
javaClass
.
getMethods
();
for
(
int
i
=
0
;
i
<
methods
.
length
;
i
++)
{
Method
m
=
methods
[
i
];
...
...
@@ -150,10 +151,6 @@ public class FunctionAlias extends DbObjectBase {
throw
Message
.
getUnsupportedException
();
}
public
Value
getValue
(
Session
session
,
Expression
[]
args
)
throws
SQLException
{
return
getValue
(
session
,
args
,
false
);
}
/**
* Call the user-defined function and return the value.
*
...
...
@@ -228,6 +225,11 @@ public class FunctionAlias extends DbObjectBase {
return
this
.
methodName
;
}
/**
* Check if this function requires a database connection.
*
* @return if the function requires a connection
*/
public
boolean
hasConnectionParam
()
{
return
this
.
hasConnectionParam
;
}
...
...
h2/src/main/org/h2/engine/UserAggregate.java
浏览文件 @
f5339ed9
...
...
@@ -13,6 +13,7 @@ import org.h2.command.Parser;
import
org.h2.message.Message
;
import
org.h2.message.Trace
;
import
org.h2.table.Table
;
import
org.h2.util.ClassUtils
;
/**
* Represents a user-defined aggregate function.
...
...
@@ -32,7 +33,7 @@ public class UserAggregate extends DbObjectBase {
public
AggregateFunction
getInstance
()
throws
SQLException
{
if
(
javaClass
==
null
)
{
javaClass
=
database
.
loadUserClass
(
className
);
javaClass
=
ClassUtils
.
loadUserClass
(
className
);
}
Object
obj
;
try
{
...
...
h2/src/main/org/h2/expression/JavaFunction.java
浏览文件 @
f5339ed9
...
...
@@ -31,7 +31,7 @@ public class JavaFunction extends Expression implements FunctionCall {
}
public
Value
getValue
(
Session
session
)
throws
SQLException
{
return
functionAlias
.
getValue
(
session
,
args
);
return
functionAlias
.
getValue
(
session
,
args
,
false
);
}
public
int
getType
()
{
...
...
h2/src/main/org/h2/schema/TriggerObject.java
浏览文件 @
f5339ed9
...
...
@@ -18,6 +18,7 @@ import org.h2.message.Message;
import
org.h2.message.Trace
;
import
org.h2.result.Row
;
import
org.h2.table.Table
;
import
org.h2.util.ClassUtils
;
import
org.h2.value.DataType
;
import
org.h2.value.Value
;
...
...
@@ -55,7 +56,7 @@ public class TriggerObject extends SchemaObjectBase {
}
try
{
Connection
c2
=
session
.
createConnection
(
false
);
Object
obj
=
session
.
getDatabase
()
.
loadUserClass
(
triggerClassName
).
newInstance
();
Object
obj
=
ClassUtils
.
loadUserClass
(
triggerClassName
).
newInstance
();
triggerCallback
=
(
Trigger
)
obj
;
triggerCallback
.
init
(
c2
,
getSchema
().
getName
(),
getName
(),
table
.
getName
(),
before
,
typeMask
);
}
catch
(
Throwable
e
)
{
...
...
h2/src/main/org/h2/tools/RunScript.java
浏览文件 @
f5339ed9
...
...
@@ -103,11 +103,7 @@ public class RunScript extends Tool {
showTime
=
true
;
}
else
if
(
arg
.
equals
(
"-driver"
))
{
String
driver
=
args
[++
i
];
try
{
ClassUtils
.
loadUserClass
(
driver
);
}
catch
(
ClassNotFoundException
e
)
{
throw
Message
.
convert
(
e
);
}
ClassUtils
.
loadUserClass
(
driver
);
}
else
if
(
arg
.
equals
(
"-options"
))
{
StringBuffer
buff
=
new
StringBuffer
();
i
++;
...
...
h2/src/main/org/h2/tools/Shell.java
浏览文件 @
f5339ed9
...
...
@@ -20,7 +20,6 @@ import java.sql.Statement;
import
java.util.Properties
;
import
org.h2.engine.Constants
;
import
org.h2.message.Message
;
import
org.h2.server.web.ConnectionInfo
;
import
org.h2.util.ClassUtils
;
import
org.h2.util.FileUtils
;
...
...
@@ -82,11 +81,7 @@ public class Shell {
password
=
args
[++
i
];
}
else
if
(
args
[
i
].
equals
(
"-driver"
))
{
String
driver
=
args
[++
i
];
try
{
ClassUtils
.
loadUserClass
(
driver
);
}
catch
(
ClassNotFoundException
e
)
{
throw
Message
.
convert
(
e
);
}
ClassUtils
.
loadUserClass
(
driver
);
}
else
{
out
.
println
(
"Unsupported option: "
+
args
[
i
]);
showUsage
();
...
...
h2/src/main/org/h2/util/ClassUtils.java
浏览文件 @
f5339ed9
...
...
@@ -48,7 +48,7 @@ public class ClassUtils {
return
Class
.
forName
(
className
);
}
public
static
Class
loadUserClass
(
String
className
)
throws
ClassNotFoundException
,
SQLException
{
public
static
Class
loadUserClass
(
String
className
)
throws
SQLException
{
if
(!
ALLOW_ALL
&&
!
ALLOWED_CLASS_NAMES
.
contains
(
className
))
{
boolean
allowed
=
false
;
for
(
int
i
=
0
;
i
<
ALLOWED_CLASS_NAME_PREFIXES
.
length
;
i
++)
{
...
...
@@ -61,7 +61,13 @@ public class ClassUtils {
throw
Message
.
getSQLException
(
ErrorCode
.
ACCESS_DENIED_TO_CLASS_1
,
className
);
}
}
return
Class
.
forName
(
className
);
try
{
return
Class
.
forName
(
className
);
}
catch
(
ClassNotFoundException
e
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
CLASS_NOT_FOUND_1
,
new
String
[]
{
className
},
e
);
}
catch
(
NoClassDefFoundError
e
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
CLASS_NOT_FOUND_1
,
new
String
[]
{
className
},
e
);
}
}
}
h2/src/main/org/h2/util/JdbcDriverUtils.java
浏览文件 @
f5339ed9
...
...
@@ -6,6 +6,8 @@
*/
package
org
.
h2
.
util
;
import
java.sql.SQLException
;
/**
* This class tries to automatically load the right JDBC driver for a given
* database URL.
...
...
@@ -50,10 +52,10 @@ public class JdbcDriverUtils {
return
null
;
}
public
static
void
load
(
String
url
)
throws
ClassNotFound
Exception
{
public
static
void
load
(
String
url
)
throws
SQL
Exception
{
String
driver
=
getDriver
(
url
);
if
(
driver
!=
null
)
{
Class
.
forName
(
driver
);
Class
Utils
.
loadUserClass
(
driver
);
}
}
...
...
h2/src/main/org/h2/util/JdbcUtils.java
浏览文件 @
f5339ed9
...
...
@@ -13,14 +13,11 @@ import java.sql.SQLException;
import
java.sql.Statement
;
import
java.util.Properties
;
//## Java 1.4 begin ##
import
javax.naming.Context
;
import
javax.naming.NamingException
;
import
javax.sql.DataSource
;
import
javax.sql.XAConnection
;
//## Java 1.4 end ##
import
org.h2.constant.ErrorCode
;
import
org.h2.message.Message
;
/**
...
...
@@ -95,43 +92,37 @@ public class JdbcUtils {
}
public
static
Connection
getConnection
(
String
driver
,
String
url
,
Properties
prop
)
throws
SQLException
{
try
{
if
(
StringUtils
.
isNullOrEmpty
(
driver
))
{
JdbcDriverUtils
.
load
(
url
);
}
else
{
Class
d
=
ClassUtils
.
loadUserClass
(
driver
);
if
(
java
.
sql
.
Driver
.
class
.
isAssignableFrom
(
d
))
{
return
DriverManager
.
getConnection
(
url
,
prop
);
//## Java 1.4 begin ##
}
else
if
(
javax
.
naming
.
Context
.
class
.
isAssignableFrom
(
d
))
{
// JNDI context
try
{
Context
context
=
(
Context
)
d
.
newInstance
();
DataSource
ds
=
(
DataSource
)
context
.
lookup
(
url
);
String
user
=
prop
.
getProperty
(
"user"
);
String
password
=
prop
.
getProperty
(
"password"
);
if
(
StringUtils
.
isNullOrEmpty
(
user
)
&&
StringUtils
.
isNullOrEmpty
(
password
))
{
return
ds
.
getConnection
();
}
else
{
return
ds
.
getConnection
(
user
,
password
);
}
}
catch
(
InstantiationException
e
)
{
throw
Message
.
convert
(
e
);
}
catch
(
IllegalAccessException
e
)
{
throw
Message
.
convert
(
e
);
}
catch
(
NamingException
e
)
{
throw
Message
.
convert
(
e
);
}
//## Java 1.4 end ##
}
else
{
// Don't know, but maybe it loaded a JDBC Driver
return
DriverManager
.
getConnection
(
url
,
prop
);
if
(
StringUtils
.
isNullOrEmpty
(
driver
))
{
JdbcDriverUtils
.
load
(
url
);
}
else
{
Class
d
=
ClassUtils
.
loadUserClass
(
driver
);
if
(
java
.
sql
.
Driver
.
class
.
isAssignableFrom
(
d
))
{
return
DriverManager
.
getConnection
(
url
,
prop
);
//## Java 1.4 begin ##
}
else
if
(
javax
.
naming
.
Context
.
class
.
isAssignableFrom
(
d
))
{
// JNDI context
try
{
Context
context
=
(
Context
)
d
.
newInstance
();
DataSource
ds
=
(
DataSource
)
context
.
lookup
(
url
);
String
user
=
prop
.
getProperty
(
"user"
);
String
password
=
prop
.
getProperty
(
"password"
);
if
(
StringUtils
.
isNullOrEmpty
(
user
)
&&
StringUtils
.
isNullOrEmpty
(
password
))
{
return
ds
.
getConnection
();
}
else
{
return
ds
.
getConnection
(
user
,
password
);
}
}
catch
(
InstantiationException
e
)
{
throw
Message
.
convert
(
e
);
}
catch
(
IllegalAccessException
e
)
{
throw
Message
.
convert
(
e
);
}
catch
(
NamingException
e
)
{
throw
Message
.
convert
(
e
);
}
}
}
catch
(
ClassNotFoundException
e
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
CLASS_NOT_FOUND_1
,
new
String
[]{
driver
},
e
);
}
catch
(
NoClassDefFoundError
e
)
{
throw
Message
.
getSQLException
(
ErrorCode
.
CLASS_NOT_FOUND_1
,
new
String
[]{
driver
},
e
);
//## Java 1.4 end ##
}
else
{
// Don't know, but maybe it loaded a JDBC Driver
return
DriverManager
.
getConnection
(
url
,
prop
);
}
}
return
DriverManager
.
getConnection
(
url
,
prop
);
}
...
...
h2/src/tools/org/h2/build/Build.java
浏览文件 @
f5339ed9
...
...
@@ -171,6 +171,7 @@ public class Build extends BuildBase {
javadoc
(
new
String
[]
{
"-sourcepath"
,
"src/main"
+
File
.
pathSeparator
+
"src/test"
+
File
.
pathSeparator
+
"src/tools"
,
"-noindex"
,
"-d"
,
"docs/javadocImpl2"
,
"-classpath"
,
"ext/servlet-api-2.4.jar"
+
File
.
pathSeparator
+
"ext/lucene-core-2.2.0.jar"
+
File
.
pathSeparator
+
System
.
getProperty
(
"java.home"
)
+
"/../lib/tools.jar"
,
"-subpackages"
,
"org.h2"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论