Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
635405a9
提交
635405a9
authored
6 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add more subclases of SQLException and use it for some error codes
上级
8813bbf4
master
version-1.4.198
无相关合并请求
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
650 行增加
和
3 行删除
+650
-3
roadmap.html
h2/src/docsrc/html/roadmap.html
+1
-2
JdbcSQLDataException.java
h2/src/main/org/h2/jdbc/JdbcSQLDataException.java
+87
-0
JdbcSQLFeatureNotSupportedException.java
...main/org/h2/jdbc/JdbcSQLFeatureNotSupportedException.java
+87
-0
JdbcSQLIntegrityConstraintViolationException.java
...h2/jdbc/JdbcSQLIntegrityConstraintViolationException.java
+88
-0
JdbcSQLInvalidAuthorizationSpecException.java
...org/h2/jdbc/JdbcSQLInvalidAuthorizationSpecException.java
+88
-0
JdbcSQLNonTransientConnectionException.java
...n/org/h2/jdbc/JdbcSQLNonTransientConnectionException.java
+88
-0
JdbcSQLSyntaxErrorException.java
h2/src/main/org/h2/jdbc/JdbcSQLSyntaxErrorException.java
+87
-0
JdbcSQLTransactionRollbackException.java
...main/org/h2/jdbc/JdbcSQLTransactionRollbackException.java
+87
-0
DbException.java
h2/src/main/org/h2/message/DbException.java
+37
-1
没有找到文件。
h2/src/docsrc/html/roadmap.html
浏览文件 @
635405a9
...
...
@@ -533,9 +533,8 @@ 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.
</li><li>
Use Java 6 SQLException subclasses
for more kinds of errors
.
</li><li>
Issue 390: RUNSCRIPT FROM '...' CONTINUE_ON_ERROR
</li><li>
Use Java 6 exceptions: SQLDataException, SQLSyntaxErrorException, SQLTimeoutException,..
</li></ul>
<h2>
Not Planned
</h2>
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcSQLDataException.java
0 → 100644
浏览文件 @
635405a9
/*
* 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.SQLDataException
;
import
org.h2.message.DbException
;
/**
* Represents a database exception.
*/
public
class
JdbcSQLDataException
extends
SQLDataException
implements
JdbcException
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
String
originalMessage
;
private
final
String
stackTrace
;
private
String
message
;
private
String
sql
;
/**
* Creates a SQLDataException.
*
* @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
JdbcSQLDataException
(
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
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcSQLFeatureNotSupportedException.java
0 → 100644
浏览文件 @
635405a9
/*
* 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.SQLFeatureNotSupportedException
;
import
org.h2.message.DbException
;
/**
* Represents a database exception.
*/
public
class
JdbcSQLFeatureNotSupportedException
extends
SQLFeatureNotSupportedException
implements
JdbcException
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
String
originalMessage
;
private
final
String
stackTrace
;
private
String
message
;
private
String
sql
;
/**
* Creates a SQLFeatureNotSupportedException.
*
* @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
JdbcSQLFeatureNotSupportedException
(
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
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcSQLIntegrityConstraintViolationException.java
0 → 100644
浏览文件 @
635405a9
/*
* 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.SQLIntegrityConstraintViolationException
;
import
org.h2.message.DbException
;
/**
* Represents a database exception.
*/
public
class
JdbcSQLIntegrityConstraintViolationException
extends
SQLIntegrityConstraintViolationException
implements
JdbcException
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
String
originalMessage
;
private
final
String
stackTrace
;
private
String
message
;
private
String
sql
;
/**
* Creates a SQLIntegrityConstraintViolationException.
*
* @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
JdbcSQLIntegrityConstraintViolationException
(
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
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcSQLInvalidAuthorizationSpecException.java
0 → 100644
浏览文件 @
635405a9
/*
* 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.SQLInvalidAuthorizationSpecException
;
import
org.h2.message.DbException
;
/**
* Represents a database exception.
*/
public
class
JdbcSQLInvalidAuthorizationSpecException
extends
SQLInvalidAuthorizationSpecException
implements
JdbcException
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
String
originalMessage
;
private
final
String
stackTrace
;
private
String
message
;
private
String
sql
;
/**
* Creates a SQLInvalidAuthorizationSpecException.
*
* @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
JdbcSQLInvalidAuthorizationSpecException
(
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
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcSQLNonTransientConnectionException.java
0 → 100644
浏览文件 @
635405a9
/*
* 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.SQLNonTransientConnectionException
;
import
org.h2.message.DbException
;
/**
* Represents a database exception.
*/
public
class
JdbcSQLNonTransientConnectionException
extends
SQLNonTransientConnectionException
implements
JdbcException
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
String
originalMessage
;
private
final
String
stackTrace
;
private
String
message
;
private
String
sql
;
/**
* Creates a SQLNonTransientConnectionException.
*
* @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
JdbcSQLNonTransientConnectionException
(
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
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcSQLSyntaxErrorException.java
0 → 100644
浏览文件 @
635405a9
/*
* 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.SQLSyntaxErrorException
;
import
org.h2.message.DbException
;
/**
* Represents a database exception.
*/
public
class
JdbcSQLSyntaxErrorException
extends
SQLSyntaxErrorException
implements
JdbcException
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
String
originalMessage
;
private
final
String
stackTrace
;
private
String
message
;
private
String
sql
;
/**
* Creates a SQLSyntaxErrorException.
*
* @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
JdbcSQLSyntaxErrorException
(
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
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/jdbc/JdbcSQLTransactionRollbackException.java
0 → 100644
浏览文件 @
635405a9
/*
* 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.SQLTransactionRollbackException
;
import
org.h2.message.DbException
;
/**
* Represents a database exception.
*/
public
class
JdbcSQLTransactionRollbackException
extends
SQLTransactionRollbackException
implements
JdbcException
{
private
static
final
long
serialVersionUID
=
1L
;
private
final
String
originalMessage
;
private
final
String
stackTrace
;
private
String
message
;
private
String
sql
;
/**
* Creates a SQLTransactionRollbackException.
*
* @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
JdbcSQLTransactionRollbackException
(
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
;
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/message/DbException.java
浏览文件 @
635405a9
...
...
@@ -20,7 +20,14 @@ import java.util.Properties;
import
org.h2.api.ErrorCode
;
import
org.h2.engine.Constants
;
import
org.h2.jdbc.JdbcException
;
import
org.h2.jdbc.JdbcSQLDataException
;
import
org.h2.jdbc.JdbcSQLException
;
import
org.h2.jdbc.JdbcSQLFeatureNotSupportedException
;
import
org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException
;
import
org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException
;
import
org.h2.jdbc.JdbcSQLNonTransientConnectionException
;
import
org.h2.jdbc.JdbcSQLSyntaxErrorException
;
import
org.h2.jdbc.JdbcSQLTransactionRollbackException
;
import
org.h2.util.SortedProperties
;
import
org.h2.util.StringUtils
;
import
org.h2.util.Utils
;
...
...
@@ -414,7 +421,36 @@ public class DbException extends RuntimeException {
*/
public
static
SQLException
getJdbcSQLException
(
String
message
,
String
sql
,
String
state
,
int
errorCode
,
Throwable
cause
,
String
stackTrace
)
{
return
new
JdbcSQLException
(
message
,
filterSQL
(
sql
),
state
,
errorCode
,
cause
,
stackTrace
);
sql
=
filterSQL
(
sql
);
// Use SQLState class value to detect type
switch
(
errorCode
/
1_000
)
{
case
8
:
return
new
JdbcSQLNonTransientConnectionException
(
message
,
sql
,
state
,
errorCode
,
cause
,
stackTrace
);
case
22
:
return
new
JdbcSQLDataException
(
message
,
sql
,
state
,
errorCode
,
cause
,
stackTrace
);
case
23
:
return
new
JdbcSQLIntegrityConstraintViolationException
(
message
,
sql
,
state
,
errorCode
,
cause
,
stackTrace
);
case
28
:
return
new
JdbcSQLInvalidAuthorizationSpecException
(
message
,
sql
,
state
,
errorCode
,
cause
,
stackTrace
);
case
40
:
return
new
JdbcSQLTransactionRollbackException
(
message
,
sql
,
state
,
errorCode
,
cause
,
stackTrace
);
case
42
:
return
new
JdbcSQLSyntaxErrorException
(
message
,
sql
,
state
,
errorCode
,
cause
,
stackTrace
);
}
// Check error code
switch
(
errorCode
){
case
ErrorCode
.
FEATURE_NOT_SUPPORTED_1
:
return
new
JdbcSQLFeatureNotSupportedException
(
message
,
sql
,
state
,
errorCode
,
cause
,
stackTrace
);
case
ErrorCode
.
HEX_STRING_ODD_1
:
case
ErrorCode
.
HEX_STRING_WRONG_1
:
case
ErrorCode
.
INVALID_VALUE_2
:
case
ErrorCode
.
PARSE_ERROR_1
:
case
ErrorCode
.
INVALID_TO_DATE_FORMAT
:
case
ErrorCode
.
STRING_FORMAT_ERROR_1
:
return
new
JdbcSQLDataException
(
message
,
sql
,
state
,
errorCode
,
cause
,
stackTrace
);
}
// Default
return
new
JdbcSQLException
(
message
,
sql
,
state
,
errorCode
,
cause
,
stackTrace
);
}
private
static
String
filterSQL
(
String
sql
)
{
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论