public class BatchUpdateException extends SQLException
SQLException的子类。
除了SQLException提供的信息外 , BatchUpdateException还提供了在批量更新期间成功执行的所有命令的更新计数,即在发生错误之前执行的所有命令。
更新计数数组中元素的顺序对应于将命令添加到批次的顺序。
在批处理更新中的命令无法正常执行并且抛出BatchUpdateException之后,驱动程序可能会继续处理或者不再继续处理批处理中的剩余命令。 如果驱动程序在故障后继续处理,方法BatchUpdateException.getUpdateCounts返回的数组将为批处理中的每个命令都有一个元素,而不仅仅是在错误之前成功执行的命令的元素。 在驱动程序继续处理命令的情况下,任何失败命令的数组元素为Statement.EXECUTE_FAILED 。
JDBC驱动程序实现应该使用构造函数BatchUpdateException(String reason, String SQLState, int vendorCode, long []updateCounts,Throwable cause)而不是使用int[]作为更新计数的构造函数,以避免溢出的可能性。
如果Statement.executeLargeBatch方法被调用时,建议getLargeUpdateCounts被调用,而不是getUpdateCounts为了避免整数更新计数的可能溢出。
| Constructor and Description |
|---|
BatchUpdateException()
构造一个
BatchUpdateException对象。
|
BatchUpdateException(int[] updateCounts)
构造一个
BatchUpdateException对象,初始化为给定的
updateCounts 。
|
BatchUpdateException(int[] updateCounts, Throwable cause)
构造一个
BatchUpdateException对象,初始化为给定的
cause和
updateCounts 。
|
BatchUpdateException(String reason, int[] updateCounts)
构造一个
BatchUpdateException对象,该对象使用给定的
reason和
updateCounts 。
|
BatchUpdateException(String reason, int[] updateCounts, Throwable cause)
构造一个
BatchUpdateException与给定的初始化的对象
reason ,
cause和
updateCounts 。
|
BatchUpdateException(String reason, String SQLState, int[] updateCounts)
构造一个
BatchUpdateException与给定的初始化的对象
reason ,
SQLState和
updateCounts 。
|
BatchUpdateException(String reason, String SQLState, int[] updateCounts, Throwable cause)
构造一个
BatchUpdateException与给定的初始化的对象
reason ,
SQLState ,
cause和
updateCounts 。
|
BatchUpdateException(String reason, String SQLState, int vendorCode, int[] updateCounts)
构造一个
BatchUpdateException与给定的初始化的对象
reason ,
SQLState ,
vendorCode和
updateCounts 。
|
BatchUpdateException(String reason, String SQLState, int vendorCode, int[] updateCounts, Throwable cause)
构造一个
BatchUpdateException与给定的初始化的对象
reason ,
SQLState ,
vendorCode
cause和
updateCounts 。
|
BatchUpdateException(String reason, String SQLState, int vendorCode, long[] updateCounts, Throwable cause)
构造一个
BatchUpdateException与给定的初始化的对象
reason ,
SQLState ,
vendorCode
cause和
updateCounts 。
|
BatchUpdateException(Throwable cause)
构造一个
BatchUpdateException对象,用一个给定的
cause 。
|
| Modifier and Type | Method and Description |
|---|---|
long[] |
getLargeUpdateCounts()
检索在发生此异常之前成功执行的批量更新中每个更新语句的更新计数。
|
int[] |
getUpdateCounts()
检索在发生此异常之前成功执行的批量更新中每个更新语句的更新计数。
|
getErrorCode, getNextException, getSQLState, iterator, setNextExceptionaddSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic BatchUpdateException(String reason, String SQLState, int vendorCode, int[] updateCounts)
BatchUpdateException与给定的初始化的对象reason , SQLState , vendorCode和updateCounts 。
cause未初始化,可以随后通过调用Throwable.initCause(java.lang.Throwable)方法初始化 。
注意:没有验证updateCounts的溢出,因此,建议您使用构造BatchUpdateException(String reason, String SQLState, int vendorCode, long []updateCounts,Throwable cause) 。
reason - 错误的描述
SQLState -
SQLState的XOPEN或SQL:2003代码
vendorCode - 特定数据库供应商使用的异常代码
updateCounts -的阵列int ,其每个元素指示的更新计数, Statement.SUCCESS_NO_INFO或Statement.EXECUTE_FAILED在批次JDBC驱动程序继续命令失败后处理中的每个SQL命令;
在命令失败后停止处理的JDBC驱动程序发生故障之前,批处理中的每个SQL命令的更新计数或Statement.SUCCESS_NO_INFO
BatchUpdateException(java.lang.String, java.lang.String, int, long[], java.lang.Throwable)
public BatchUpdateException(String reason, String SQLState, int[] updateCounts)
BatchUpdateException与给定的初始化的对象reason , SQLState和updateCounts 。
cause未初始化,可以随后通过调用Throwable.initCause(java.lang.Throwable)方法初始化 。
供应商代码初始化为0。
注意:没有验证updateCounts的溢出,因此,建议您使用构造BatchUpdateException(String reason, String SQLState, int vendorCode, long []updateCounts,Throwable cause) 。
reason - 异常的描述
SQLState - 标识该异常的XOPEN或SQL:2003代码
updateCounts -的阵列int ,其每个元素指示的更新计数, Statement.SUCCESS_NO_INFO或Statement.EXECUTE_FAILED在批次JDBC驱动程序继续命令失败后处理中的每个SQL命令;
在命令失败后停止处理的JDBC驱动程序发生故障之前,批处理中的每个SQL命令的更新计数或Statement.SUCCESS_NO_INFO
BatchUpdateException(java.lang.String, java.lang.String, int, long[], java.lang.Throwable)
public BatchUpdateException(String reason, int[] updateCounts)
BatchUpdateException对象,初始化为给定的reason和updateCounts 。
cause未初始化,可以随后通过调用Throwable.initCause(java.lang.Throwable)方法进行初始化 。
SQLState初始化为null ,供应商代码初始化为0。
注意:没有验证updateCounts的溢出,因此,建议您使用构造BatchUpdateException(String reason, String SQLState, int vendorCode, long []updateCounts,Throwable cause) 。
reason - 异常的描述
updateCounts -的阵列int ,其每个元素指示的更新计数, Statement.SUCCESS_NO_INFO或Statement.EXECUTE_FAILED在批次JDBC驱动程序继续命令失败后处理中的每个SQL命令;
在命令失败后停止处理的JDBC驱动程序发生故障之前,批处理中的每个SQL命令的更新计数或Statement.SUCCESS_NO_INFO
BatchUpdateException(java.lang.String, java.lang.String, int, long[], java.lang.Throwable)
public BatchUpdateException(int[] updateCounts)
BatchUpdateException对象,初始化为给定的updateCounts 。
通过调用Throwable.initCause(java.lang.Throwable)方法初始化 。
reason和SQLState为null,供应商代码初始化为0。
注意:没有验证updateCounts溢出,因此,建议您使用构造BatchUpdateException(String reason, String SQLState, int vendorCode, long []updateCounts,Throwable cause) 。
updateCounts -的阵列int ,其每个元素指示的更新计数, Statement.SUCCESS_NO_INFO或Statement.EXECUTE_FAILED在批次JDBC驱动程序继续命令失败后处理中的每个SQL命令;
在命令失败后停止处理的JDBC驱动程序发生故障之前,批处理中的每个SQL命令的更新计数或Statement.SUCCESS_NO_INFO
BatchUpdateException(java.lang.String, java.lang.String, int, long[], java.lang.Throwable)
public BatchUpdateException()
BatchUpdateException对象。
的reason , SQLState和updateCounts被初始化为null ,供应商代码被初始化为0。 cause没有初始化,随后可以通过向一个呼叫进行初始化Throwable.initCause(java.lang.Throwable)方法。
public BatchUpdateException(Throwable cause)
BatchUpdateException对象,初始化为给定的cause 。
的SQLState和updateCounts被初始化为null ,供应商代码被初始化为0。 reason被初始化为null如果cause==null ,或cause.toString()如果cause!=null 。
cause -底层原因SQLException (保存用于由稍后检索getCause()方法);
可能为空,表示原因不存在或未知。
BatchUpdateException(java.lang.String, java.lang.String, int, long[], java.lang.Throwable)
public BatchUpdateException(int[] updateCounts,
Throwable cause)
BatchUpdateException对象,初始化为给定的cause和updateCounts 。
该SQLState被初始化为null ,供应商代码被初始化为0。 reason被初始化为null如果cause==null ,或cause.toString()如果cause!=null 。
注意:没有验证updateCounts的溢出,因此,建议您使用构造BatchUpdateException(String reason, String SQLState, int vendorCode, long []updateCounts,Throwable cause) 。
updateCounts -的阵列int ,其每个元素指示的更新计数, Statement.SUCCESS_NO_INFO或Statement.EXECUTE_FAILED在批次JDBC驱动程序继续命令失败后处理中的每个SQL命令;
在命令失败后停止处理的JDBC驱动程序发生故障之前,批处理中的每个SQL命令的更新计数或Statement.SUCCESS_NO_INFO
cause -底层原因SQLException (保存用于由稍后检索getCause()方法);
可能为空,表示原因不存在或未知。
BatchUpdateException(java.lang.String, java.lang.String, int, long[], java.lang.Throwable)
public BatchUpdateException(String reason, int[] updateCounts, Throwable cause)
BatchUpdateException与给定的初始化的对象reason , cause和updateCounts 。
SQLState初始化为null ,供应商代码初始化为0。
注意:没有验证updateCounts溢出,因此建议您使用构造BatchUpdateException(String reason, String SQLState, int vendorCode, long []updateCounts,Throwable cause) 。
reason - 异常的描述
updateCounts -的阵列int ,其每个元素指示的更新计数, Statement.SUCCESS_NO_INFO或Statement.EXECUTE_FAILED在批次JDBC驱动程序继续命令失败后处理中的每个SQL命令;
在命令失败后停止处理的JDBC驱动程序发生故障之前,批处理中的每个SQL命令的更新计数或Statement.SUCCESS_NO_INFO
cause -底层原因SQLException (保存用于由稍后检索getCause()方法);
可能为空,表示原因不存在或未知。
BatchUpdateException(java.lang.String, java.lang.String, int, long[], java.lang.Throwable)
public BatchUpdateException(String reason, String SQLState, int[] updateCounts, Throwable cause)
BatchUpdateException与给定的初始化的对象reason , SQLState , cause和updateCounts 。
供应商代码初始化为0。
reason - 异常的描述
SQLState -
SQLState的XOPEN或SQL:2003代码
updateCounts -的阵列int ,其每个元素指示的更新计数, Statement.SUCCESS_NO_INFO或Statement.EXECUTE_FAILED在批次JDBC驱动程序继续命令失败后处理中的每个SQL命令;
在命令失败后停止处理的JDBC驱动程序发生故障之前,批处理中的每个SQL命令的更新计数或Statement.SUCCESS_NO_INFO
注意:没有验证updateCounts溢出,因此,建议您使用构造BatchUpdateException(String reason, String SQLState, int vendorCode, long []updateCounts,Throwable cause) 。
cause - 这个SQLException (其保存以供稍后通过getCause()方法cause )的根本原因;
可能为空,表示原因不存在或未知。
BatchUpdateException(java.lang.String, java.lang.String, int, long[], java.lang.Throwable)
public BatchUpdateException(String reason, String SQLState, int vendorCode, int[] updateCounts, Throwable cause)
BatchUpdateException与给定的初始化的对象
reason ,
SQLState ,
vendorCode
cause和
updateCounts 。
reason - 错误的描述
SQLState -
SQLState的XOPEN或SQL:2003代码
vendorCode - 特定数据库供应商使用的异常代码
updateCounts -的阵列int ,其每个元素指示的更新计数, Statement.SUCCESS_NO_INFO或Statement.EXECUTE_FAILED在批次JDBC驱动程序继续命令失败后处理中的每个SQL命令;
在命令失败后停止处理的JDBC驱动程序发生故障之前,批处理中的每个SQL命令的更新计数或Statement.SUCCESS_NO_INFO
注:没有验证updateCounts溢出正因为如此,建议你使用构造BatchUpdateException(String reason, String SQLState, int vendorCode, long []updateCounts,Throwable cause) 。
cause -底层原因SQLException (保存用于由稍后检索getCause()方法);
可能为空,表示原因不存在或未知。
BatchUpdateException(java.lang.String, java.lang.String, int, long[], java.lang.Throwable)
public BatchUpdateException(String reason, String SQLState, int vendorCode, long[] updateCounts, Throwable cause)
BatchUpdateException与给定的初始化的对象reason , SQLState , vendorCode cause和updateCounts 。
当返回的更新计数可能超过Integer.MAX_VALUE时,应使用此构造函数 。
reason - 错误的描述
SQLState -
SQLState的XOPEN或SQL:2003代码
vendorCode - 特定数据库供应商使用的异常代码
updateCounts -的阵列long ,其每个元素指示的更新计数, Statement.SUCCESS_NO_INFO或Statement.EXECUTE_FAILED在批次JDBC驱动程序继续命令失败后处理中的每个SQL命令;
在命令失败后停止处理的JDBC驱动程序发生故障之前,批处理中的每个SQL命令的更新计数或Statement.SUCCESS_NO_INFO
cause -底层原因SQLException (保存用于由稍后检索getCause()方法);
可能为空,表示原因不存在或未知。
public int[] getUpdateCounts()
BatchUpdateException执行的每个命令的更新计数。
针对Java 2 SDK(Standard Edition,版本1.3)修改了此方法的可能返回值。 这是为了适应在抛出BatchUpdateException对象之后,在批量更新中继续处理命令的新选项。
int ,其中包含在此错误发生之前成功执行的更新的更新计数。
或者,如果驱动程序在错误后继续处理命令,则批处理中的每个命令都将执行以下操作之一:
Statement.SUCCESS_NO_INFO指示命令执行成功但受影响的行数未知 Statement.EXECUTE_FAILED指示命令无法成功执行 getLargeUpdateCounts()
public long[] getLargeUpdateCounts()
BatchUpdateException执行的每个命令的更新计数。
当调用Statement.executeLargeBatch时,应使用此方法,返回的更新计数可能超过Integer.MAX_VALUE 。
long ,其中包含在此错误发生之前成功执行的更新的更新计数。
或者,如果驱动程序在错误后继续处理命令,则批处理中的每个命令都将执行以下操作之一:
Statement.SUCCESS_NO_INFO指示命令执行成功但受影响的行数未知 Statement.EXECUTE_FAILED指示命令无法成功执行 Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.