Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
0ff4499b
Unverified
提交
0ff4499b
authored
8月 28, 2018
作者:
Evgenij Ryazanov
提交者:
GitHub
8月 28, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1409 from katzyn/exception
Map all remaining error codes to custom exception classes
上级
d0c4469a
3ad7a145
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
503 行增加
和
45 行删除
+503
-45
changelog.html
h2/src/docsrc/html/changelog.html
+2
-0
roadmap.html
h2/src/docsrc/html/roadmap.html
+0
-1
ErrorCode.java
h2/src/main/org/h2/api/ErrorCode.java
+1
-11
JdbcSQLNonTransientException.java
h2/src/main/org/h2/jdbc/JdbcSQLNonTransientException.java
+87
-0
JdbcSQLTimeoutException.java
h2/src/main/org/h2/jdbc/JdbcSQLTimeoutException.java
+87
-0
JdbcSQLTransientException.java
h2/src/main/org/h2/jdbc/JdbcSQLTransientException.java
+87
-0
DbException.java
h2/src/main/org/h2/message/DbException.java
+182
-33
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+2
-0
TestDbException.java
h2/src/test/org/h2/test/unit/TestDbException.java
+55
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
0ff4499b
...
...
@@ -21,6 +21,8 @@ Change Log
<h2>
Next Version (unreleased)
</h2>
<ul>
<li>
PR #1409: Map all remaining error codes to custom exception classes
</li>
<li>
Issue #1407: Add a MODE() aggregate function
</li>
<li>
PR #1402: Duplicate conditions in column check constraint
...
...
h2/src/docsrc/html/roadmap.html
浏览文件 @
0ff4499b
...
...
@@ -533,7 +533,6 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>
Long running transactions: log session id when detected.
</li><li>
Optimization: "select id from test" should use the index on id even without "order by".
</li><li>
Sybase SQL Anywhere compatibility: SELECT TOP ... START AT ...
</li><li>
Use Java 6 SQLException subclasses for more kinds of errors.
</li><li>
Issue 390: RUNSCRIPT FROM '...' CONTINUE_ON_ERROR
</li></ul>
...
...
h2/src/main/org/h2/api/ErrorCode.java
浏览文件 @
0ff4499b
...
...
@@ -1926,16 +1926,6 @@ public class ErrorCode {
*/
public
static
final
int
DATABASE_IS_IN_EXCLUSIVE_MODE
=
90135
;
/**
* The error with code <code>90136</code> is thrown when
* executing a query that used an unsupported outer join condition.
* Example:
* <pre>
* SELECT * FROM DUAL A LEFT JOIN DUAL B ON B.X=(SELECT MAX(X) FROM DUAL);
* </pre>
*/
public
static
final
int
UNSUPPORTED_OUTER_JOIN_CONDITION_1
=
90136
;
/**
* The error with code <code>90137</code> is thrown when
* trying to assign a value to something that is not a variable.
...
...
@@ -2019,7 +2009,7 @@ public class ErrorCode {
public
static
final
int
AUTHENTICATOR_NOT_AVAILABLE
=
90144
;
// next
is
90145
// next
are 90136,
90145
private
ErrorCode
()
{
// utility class
...
...
h2/src/main/org/h2/jdbc/JdbcSQLNonTransientException.java
0 → 100644
浏览文件 @
0ff4499b
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
jdbc
;
import
java.io.PrintStream
;
import
java.io.PrintWriter
;
import
java.sql.SQLNonTransientException
;
import
org.h2.message.DbException
;
/**
* Represents a database exception.
*/
public
class
JdbcSQLNonTransientException
extends
SQLNonTransientException
implements
JdbcException
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
String
originalMessage
;
private
final
String
stackTrace
;
private
String
message
;
private
String
sql
;
/**
* Creates a SQLNonTransientException.
*
* @param message the reason
* @param sql the SQL statement
* @param state the SQL state
* @param errorCode the error code
* @param cause the exception that was the reason for this exception
* @param stackTrace the stack trace
*/
public
JdbcSQLNonTransientException
(
String
message
,
String
sql
,
String
state
,
int
errorCode
,
Throwable
cause
,
String
stackTrace
)
{
super
(
message
,
state
,
errorCode
);
this
.
originalMessage
=
message
;
this
.
stackTrace
=
stackTrace
;
// setSQL() also generates message
setSQL
(
sql
);
initCause
(
cause
);
}
@Override
public
String
getMessage
()
{
return
message
;
}
@Override
public
String
getOriginalMessage
()
{
return
originalMessage
;
}
@Override
public
void
printStackTrace
(
PrintWriter
s
)
{
super
.
printStackTrace
(
s
);
DbException
.
printNextExceptions
(
this
,
s
);
}
@Override
public
void
printStackTrace
(
PrintStream
s
)
{
super
.
printStackTrace
(
s
);
DbException
.
printNextExceptions
(
this
,
s
);
}
@Override
public
String
getSQL
()
{
return
sql
;
}
@Override
public
void
setSQL
(
String
sql
)
{
this
.
sql
=
sql
;
message
=
DbException
.
buildMessageForException
(
this
);
}
@Override
public
String
toString
()
{
if
(
stackTrace
==
null
)
{
return
super
.
toString
();
}
return
stackTrace
;
}
}
h2/src/main/org/h2/jdbc/JdbcSQLTimeoutException.java
0 → 100644
浏览文件 @
0ff4499b
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
jdbc
;
import
java.io.PrintStream
;
import
java.io.PrintWriter
;
import
java.sql.SQLTimeoutException
;
import
org.h2.message.DbException
;
/**
* Represents a database exception.
*/
public
class
JdbcSQLTimeoutException
extends
SQLTimeoutException
implements
JdbcException
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
String
originalMessage
;
private
final
String
stackTrace
;
private
String
message
;
private
String
sql
;
/**
* Creates a SQLTimeoutException.
*
* @param message the reason
* @param sql the SQL statement
* @param state the SQL state
* @param errorCode the error code
* @param cause the exception that was the reason for this exception
* @param stackTrace the stack trace
*/
public
JdbcSQLTimeoutException
(
String
message
,
String
sql
,
String
state
,
int
errorCode
,
Throwable
cause
,
String
stackTrace
)
{
super
(
message
,
state
,
errorCode
);
this
.
originalMessage
=
message
;
this
.
stackTrace
=
stackTrace
;
// setSQL() also generates message
setSQL
(
sql
);
initCause
(
cause
);
}
@Override
public
String
getMessage
()
{
return
message
;
}
@Override
public
String
getOriginalMessage
()
{
return
originalMessage
;
}
@Override
public
void
printStackTrace
(
PrintWriter
s
)
{
super
.
printStackTrace
(
s
);
DbException
.
printNextExceptions
(
this
,
s
);
}
@Override
public
void
printStackTrace
(
PrintStream
s
)
{
super
.
printStackTrace
(
s
);
DbException
.
printNextExceptions
(
this
,
s
);
}
@Override
public
String
getSQL
()
{
return
sql
;
}
@Override
public
void
setSQL
(
String
sql
)
{
this
.
sql
=
sql
;
message
=
DbException
.
buildMessageForException
(
this
);
}
@Override
public
String
toString
()
{
if
(
stackTrace
==
null
)
{
return
super
.
toString
();
}
return
stackTrace
;
}
}
h2/src/main/org/h2/jdbc/JdbcSQLTransientException.java
0 → 100644
浏览文件 @
0ff4499b
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
jdbc
;
import
java.io.PrintStream
;
import
java.io.PrintWriter
;
import
java.sql.SQLTransientException
;
import
org.h2.message.DbException
;
/**
* Represents a database exception.
*/
public
class
JdbcSQLTransientException
extends
SQLTransientException
implements
JdbcException
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
String
originalMessage
;
private
final
String
stackTrace
;
private
String
message
;
private
String
sql
;
/**
* Creates a SQLTransientException.
*
* @param message the reason
* @param sql the SQL statement
* @param state the SQL state
* @param errorCode the error code
* @param cause the exception that was the reason for this exception
* @param stackTrace the stack trace
*/
public
JdbcSQLTransientException
(
String
message
,
String
sql
,
String
state
,
int
errorCode
,
Throwable
cause
,
String
stackTrace
)
{
super
(
message
,
state
,
errorCode
);
this
.
originalMessage
=
message
;
this
.
stackTrace
=
stackTrace
;
// setSQL() also generates message
setSQL
(
sql
);
initCause
(
cause
);
}
@Override
public
String
getMessage
()
{
return
message
;
}
@Override
public
String
getOriginalMessage
()
{
return
originalMessage
;
}
@Override
public
void
printStackTrace
(
PrintWriter
s
)
{
super
.
printStackTrace
(
s
);
DbException
.
printNextExceptions
(
this
,
s
);
}
@Override
public
void
printStackTrace
(
PrintStream
s
)
{
super
.
printStackTrace
(
s
);
DbException
.
printNextExceptions
(
this
,
s
);
}
@Override
public
String
getSQL
()
{
return
sql
;
}
@Override
public
void
setSQL
(
String
sql
)
{
this
.
sql
=
sql
;
message
=
DbException
.
buildMessageForException
(
this
);
}
@Override
public
String
toString
()
{
if
(
stackTrace
==
null
)
{
return
super
.
toString
();
}
return
stackTrace
;
}
}
h2/src/main/org/h2/message/DbException.java
浏览文件 @
0ff4499b
差异被折叠。
点击展开。
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
0ff4499b
...
...
@@ -180,6 +180,7 @@ import org.h2.test.unit.TestDataPage;
import
org.h2.test.unit.TestDate
;
import
org.h2.test.unit.TestDateIso8601
;
import
org.h2.test.unit.TestDateTimeUtils
;
import
org.h2.test.unit.TestDbException
;
import
org.h2.test.unit.TestExit
;
import
org.h2.test.unit.TestFile
;
import
org.h2.test.unit.TestFileLock
;
...
...
@@ -956,6 +957,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
addTest
(
new
TestClearReferences
());
addTest
(
new
TestDataPage
());
addTest
(
new
TestDateIso8601
());
addTest
(
new
TestDbException
());
addTest
(
new
TestFile
());
addTest
(
new
TestFtp
());
addTest
(
new
TestInterval
());
...
...
h2/src/test/org/h2/test/unit/TestDbException.java
0 → 100644
浏览文件 @
0ff4499b
/*
* Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
test
.
unit
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Modifier
;
import
java.sql.SQLException
;
import
org.h2.api.ErrorCode
;
import
org.h2.jdbc.JdbcException
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.message.DbException
;
import
org.h2.test.TestBase
;
/**
* Tests DbException class.
*/
public
class
TestDbException
extends
TestBase
{
/**
* Run just this test.
*
* @param a
* ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
@Override
public
void
test
()
throws
Exception
{
testGetJdbcSQLException
();
}
private
void
testGetJdbcSQLException
()
throws
Exception
{
for
(
Field
field
:
ErrorCode
.
class
.
getDeclaredFields
())
{
if
(
field
.
getModifiers
()
==
(
Modifier
.
PUBLIC
|
Modifier
.
STATIC
|
Modifier
.
FINAL
))
{
int
errorCode
=
field
.
getInt
(
null
);
SQLException
exception
=
DbException
.
getJdbcSQLException
(
errorCode
);
if
(
exception
instanceof
JdbcSQLException
)
{
fail
(
"Custom exception expected for "
+
ErrorCode
.
class
.
getName
()
+
'.'
+
field
.
getName
()
+
" ("
+
errorCode
+
')'
);
}
if
(!(
exception
instanceof
JdbcException
))
{
fail
(
"Custom exception for "
+
ErrorCode
.
class
.
getName
()
+
'.'
+
field
.
getName
()
+
" ("
+
errorCode
+
") should implement JdbcException"
);
}
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论