Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
4fec0303
Unverified
提交
4fec0303
authored
2月 10, 2019
作者:
Evgenij Ryazanov
提交者:
GitHub
2月 10, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1731 from katzyn/console
Detect unsupported URLs for the driver in JdbcUtils.getConnection()
上级
1fc1d43e
2fe5bd88
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
30 行增加
和
36 行删除
+30
-36
changelog.html
h2/src/docsrc/html/changelog.html
+2
-0
WebServer.java
h2/src/main/org/h2/server/web/WebServer.java
+1
-14
JdbcUtils.java
h2/src/main/org/h2/util/JdbcUtils.java
+17
-15
TestTools.java
h2/src/test/org/h2/test/unit/TestTools.java
+9
-6
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-1
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
4fec0303
...
@@ -21,6 +21,8 @@ Change Log
...
@@ -21,6 +21,8 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul>
<ul>
<li>
Issue #1730: console can no longer connect to psql dbs in v1.4.197 (works in v1.4.196)
</li>
<li>
Issue #1590: Error on executing "DELETE FROM table1 WHERE ID = ?; DELETE FROM table2 WHERE ID = ?;"
<li>
Issue #1590: Error on executing "DELETE FROM table1 WHERE ID = ?; DELETE FROM table2 WHERE ID = ?;"
</li>
</li>
<li>
Issue #1727: Support ISODOW as identifier for the extract function additional to ISO_DAY_OF_WEEK
<li>
Issue #1727: Support ISODOW as identifier for the extract function additional to ISO_DAY_OF_WEEK
...
...
h2/src/main/org/h2/server/web/WebServer.java
浏览文件 @
4fec0303
...
@@ -724,7 +724,6 @@ public class WebServer implements Service {
...
@@ -724,7 +724,6 @@ public class WebServer implements Service {
String
password
)
throws
SQLException
{
String
password
)
throws
SQLException
{
driver
=
driver
.
trim
();
driver
=
driver
.
trim
();
databaseUrl
=
databaseUrl
.
trim
();
databaseUrl
=
databaseUrl
.
trim
();
org
.
h2
.
Driver
.
load
();
Properties
p
=
new
Properties
();
Properties
p
=
new
Properties
();
p
.
setProperty
(
"user"
,
user
.
trim
());
p
.
setProperty
(
"user"
,
user
.
trim
());
// do not trim the password, otherwise an
// do not trim the password, otherwise an
...
@@ -734,19 +733,7 @@ public class WebServer implements Service {
...
@@ -734,19 +733,7 @@ public class WebServer implements Service {
if
(
ifExists
)
{
if
(
ifExists
)
{
databaseUrl
+=
";IFEXISTS=TRUE"
;
databaseUrl
+=
";IFEXISTS=TRUE"
;
}
}
// PostgreSQL would throw a NullPointerException
// if it is loaded before the H2 driver
// because it can't deal with non-String objects in the connection
// Properties
return
org
.
h2
.
Driver
.
load
().
connect
(
databaseUrl
,
p
);
}
}
// try {
// Driver dr = (Driver) urlClassLoader.
// loadClass(driver).newInstance();
// return dr.connect(url, p);
// } catch(ClassNotFoundException e2) {
// throw e2;
// }
return
JdbcUtils
.
getConnection
(
driver
,
databaseUrl
,
p
);
return
JdbcUtils
.
getConnection
(
driver
,
databaseUrl
,
p
);
}
}
...
...
h2/src/main/org/h2/util/JdbcUtils.java
浏览文件 @
4fec0303
...
@@ -288,17 +288,21 @@ public class JdbcUtils {
...
@@ -288,17 +288,21 @@ public class JdbcUtils {
JdbcUtils
.
load
(
url
);
JdbcUtils
.
load
(
url
);
}
else
{
}
else
{
Class
<?>
d
=
loadUserClass
(
driver
);
Class
<?>
d
=
loadUserClass
(
driver
);
if
(
java
.
sql
.
Driver
.
class
.
isAssignableFrom
(
d
))
{
try
{
try
{
if
(
java
.
sql
.
Driver
.
class
.
isAssignableFrom
(
d
))
{
Driver
driverInstance
=
(
Driver
)
d
.
getDeclaredConstructor
().
newInstance
();
Driver
driverInstance
=
(
Driver
)
d
.
getDeclaredConstructor
().
newInstance
();
return
driverInstance
.
connect
(
url
,
prop
);
/*fix issue #695 with drivers with the same
/*
jdbc subprotocol in classpath of jdbc drivers (as example redshift and postgresql drivers)*/
* fix issue #695 with drivers with the same jdbc
}
catch
(
Exception
e
)
{
* subprotocol in classpath of jdbc drivers (as example
throw
DbException
.
toSQLException
(
e
);
* redshift and postgresql drivers)
*/
Connection
connection
=
driverInstance
.
connect
(
url
,
prop
);
if
(
connection
!=
null
)
{
return
connection
;
}
}
throw
new
SQLException
(
"Driver "
+
driver
+
" is not suitable for "
+
url
,
"08001"
);
}
else
if
(
javax
.
naming
.
Context
.
class
.
isAssignableFrom
(
d
))
{
}
else
if
(
javax
.
naming
.
Context
.
class
.
isAssignableFrom
(
d
))
{
// JNDI context
// JNDI context
try
{
Context
context
=
(
Context
)
d
.
getDeclaredConstructor
().
newInstance
();
Context
context
=
(
Context
)
d
.
getDeclaredConstructor
().
newInstance
();
DataSource
ds
=
(
DataSource
)
context
.
lookup
(
url
);
DataSource
ds
=
(
DataSource
)
context
.
lookup
(
url
);
String
user
=
prop
.
getProperty
(
"user"
);
String
user
=
prop
.
getProperty
(
"user"
);
...
@@ -307,13 +311,11 @@ public class JdbcUtils {
...
@@ -307,13 +311,11 @@ public class JdbcUtils {
return
ds
.
getConnection
();
return
ds
.
getConnection
();
}
}
return
ds
.
getConnection
(
user
,
password
);
return
ds
.
getConnection
(
user
,
password
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
DbException
.
toSQLException
(
e
);
throw
DbException
.
toSQLException
(
e
);
}
}
}
else
{
// don't know, but maybe it loaded a JDBC Driver
// don't know, but maybe it loaded a JDBC Driver
return
DriverManager
.
getConnection
(
url
,
prop
);
}
}
}
return
DriverManager
.
getConnection
(
url
,
prop
);
return
DriverManager
.
getConnection
(
url
,
prop
);
}
}
...
...
h2/src/test/org/h2/test/unit/TestTools.java
浏览文件 @
4fec0303
...
@@ -510,12 +510,15 @@ public class TestTools extends TestDb {
...
@@ -510,12 +510,15 @@ public class TestTools extends TestDb {
}
}
private
void
testJdbcDriverUtils
()
{
private
void
testJdbcDriverUtils
()
{
assertEquals
(
"org.h2.Driver"
,
assertEquals
(
"org.h2.Driver"
,
JdbcUtils
.
getDriver
(
"jdbc:h2:~/test"
));
JdbcUtils
.
getDriver
(
"jdbc:h2:~/test"
));
assertEquals
(
"org.postgresql.Driver"
,
JdbcUtils
.
getDriver
(
"jdbc:postgresql:test"
));
assertEquals
(
"org.postgresql.Driver"
,
assertEquals
(
null
,
JdbcUtils
.
getDriver
(
"jdbc:unknown:test"
));
JdbcUtils
.
getDriver
(
"jdbc:postgresql:test"
));
try
{
assertEquals
(
null
,
JdbcUtils
.
getConnection
(
"org.h2.Driver"
,
"jdbc:h2x:test"
,
"sa"
,
""
);
JdbcUtils
.
getDriver
(
"jdbc:unknown:test"
));
fail
(
"Expected SQLException: 08001"
);
}
catch
(
SQLException
e
)
{
assertEquals
(
"08001"
,
e
.
getSQLState
());
}
}
}
private
void
testWrongServer
()
throws
Exception
{
private
void
testWrongServer
()
throws
Exception
{
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
4fec0303
...
@@ -807,4 +807,4 @@ analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin d
...
@@ -807,4 +807,4 @@ analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin d
corrupts splitted disruption unintentional octets preconditions predicates subq objectweb insn opcodes
corrupts splitted disruption unintentional octets preconditions predicates subq objectweb insn opcodes
preserves masking holder unboxing avert iae transformed subtle reevaluate exclusions subclause ftbl rgr
preserves masking holder unboxing avert iae transformed subtle reevaluate exclusions subclause ftbl rgr
presorted inclusion contexts aax mwd percentile cont interpolate mwa hypothetical regproc childed listagg foreground
presorted inclusion contexts aax mwd percentile cont interpolate mwa hypothetical regproc childed listagg foreground
isodow isoyear
isodow isoyear
psql
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论