Package org.apache.derby.client.am
Class Sqlca
- java.lang.Object
-
- org.apache.derby.client.am.Sqlca
-
- Direct Known Subclasses:
NetSqlca
public abstract class Sqlca extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private Agentagent_private java.lang.String[]cachedMessagesCached error messages (to prevent multiple invocations of the stored procedure to get the same message).private ClientConnectionconnection_private booleancontainsSqlcax_private static java.lang.StringelevenBlanks(package private) SqlExceptionexceptionThrownOnStoredProcInvocation_private static intHIGH_ORDER_ROW_COUNTprivate static intHIGH_ORDER_UPDATE_COUNTprivate static intLOW_ORDER_ROW_COUNTprivate static intLOW_ORDER_UPDATE_COUNT(package private) booleanmessageTextRetrievedContainsTokensOnly_private booleanreturnTokensOnlyInMessageText_private longrowsetRowCount_static intSQL_ERR_LENGTHprotected intsqlCode_protected int[]sqlErrd_private java.lang.StringsqlErrmc_A string representation ofsqlErrmcBytes_.protected byte[]sqlErrmcBytes_private java.lang.String[]sqlErrmcMessages_Array of errmc strings for each message in the chain.private java.lang.StringsqlErrp_protected byte[]sqlErrpBytes_protected java.lang.StringsqlState_private java.lang.String[]sqlStates_SQL states for all the messages in the exception chain.private java.lang.StringsqlWarn_protected byte[]sqlWarnBytes_
-
Constructor Summary
Constructors Modifier Constructor Description protectedSqlca(ClientConnection connection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Stringbytes2String(byte[] bytes, int offset, int length)private voidchainDeferredExceptionsToAgentOrAsConnectionWarnings(SqlException e)booleancontainsSqlcax()(package private) java.lang.StringformatSqlErrd()java.lang.Object[]getArgs(int messageNumber)(package private) java.sql.DataTruncationgetDataTruncation()Get ajava.sql.DataTruncationwarning based on the information in this SQLCA.intgetErrorCode()Get the error code based on the SQL code received from the server.(package private) java.lang.StringgetJDBCMessage(int messageNumber)private java.lang.StringgetMessage(int messageNumber)longgetRowCount()longgetRowsetRowCount()intgetSqlCode()private int[]getSqlErrd()java.lang.StringgetSqlErrmc()java.lang.StringgetSqlErrp()java.lang.StringgetSqlState()(package private) java.lang.StringgetSqlState(int messageNumber)Get the SQL state for a given error.java.lang.StringgetSqlWarn()private java.lang.StringgetUnformattedMessage(int messageNumber)Get the unformatted message text (in case we cannot ask the server).longgetUpdateCount()private voidinitSqlErrmcMessages()Initialize and build the arrayssqlErrmcMessages_andsqlStates_.(package private) intnumberOfMessages()Returns the number of messages this SQLCA contains.private voidprocessSqlErrmcTokens(byte[] tokenBytes)voidresetRowsetSqlca(ClientConnection connection, int sqlCode, java.lang.String sqlState)(package private) voidreturnTokensOnlyInMessageText(boolean returnTokensOnlyInMessageText)voidsetContainsSqlcax(boolean containsSqlcax)voidsetRowsetRowCount(long rowCount)
-
-
-
Field Detail
-
HIGH_ORDER_ROW_COUNT
private static final int HIGH_ORDER_ROW_COUNT
- See Also:
- Constant Field Values
-
LOW_ORDER_ROW_COUNT
private static final int LOW_ORDER_ROW_COUNT
- See Also:
- Constant Field Values
-
LOW_ORDER_UPDATE_COUNT
private static final int LOW_ORDER_UPDATE_COUNT
- See Also:
- Constant Field Values
-
HIGH_ORDER_UPDATE_COUNT
private static final int HIGH_ORDER_UPDATE_COUNT
- See Also:
- Constant Field Values
-
SQL_ERR_LENGTH
public static final int SQL_ERR_LENGTH
- See Also:
- Constant Field Values
-
connection_
private transient ClientConnection connection_
-
exceptionThrownOnStoredProcInvocation_
SqlException exceptionThrownOnStoredProcInvocation_
-
messageTextRetrievedContainsTokensOnly_
boolean messageTextRetrievedContainsTokensOnly_
-
sqlCode_
protected int sqlCode_
-
sqlErrmc_
private java.lang.String sqlErrmc_
A string representation ofsqlErrmcBytes_.
-
sqlErrmcMessages_
private java.lang.String[] sqlErrmcMessages_
Array of errmc strings for each message in the chain.
-
sqlStates_
private java.lang.String[] sqlStates_
SQL states for all the messages in the exception chain.
-
sqlErrp_
private java.lang.String sqlErrp_
-
sqlErrd_
protected int[] sqlErrd_
-
sqlWarn_
private java.lang.String sqlWarn_
-
sqlState_
protected java.lang.String sqlState_
-
sqlErrmcBytes_
protected byte[] sqlErrmcBytes_
-
sqlErrpBytes_
protected byte[] sqlErrpBytes_
-
sqlWarnBytes_
protected byte[] sqlWarnBytes_
-
containsSqlcax_
private boolean containsSqlcax_
-
rowsetRowCount_
private long rowsetRowCount_
-
returnTokensOnlyInMessageText_
private boolean returnTokensOnlyInMessageText_
-
agent_
private final transient Agent agent_
-
cachedMessages
private java.lang.String[] cachedMessages
Cached error messages (to prevent multiple invocations of the stored procedure to get the same message).
-
elevenBlanks
private static final java.lang.String elevenBlanks
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Sqlca
protected Sqlca(ClientConnection connection)
-
-
Method Detail
-
returnTokensOnlyInMessageText
void returnTokensOnlyInMessageText(boolean returnTokensOnlyInMessageText)
-
numberOfMessages
int numberOfMessages()
Returns the number of messages this SQLCA contains.- Returns:
- number of messages
-
getSqlCode
public int getSqlCode()
-
getErrorCode
public int getErrorCode()
Get the error code based on the SQL code received from the server.
The conversion from SQL code to error code happens like this:
- If the SQL code is 0, there is no error code because the Sqlca doesn't represent an error. Return 0.
- If the SQL code is positive, the Sqlca represents a warning, and the SQL code represents the actual error code. Return the SQL code.
- If the SQL code is negative, the Sqlca represents an error, and
the error code is
-(sqlCode+1).
-
getSqlErrmc
public java.lang.String getSqlErrmc()
-
initSqlErrmcMessages
private void initSqlErrmcMessages()
Initialize and build the arrayssqlErrmcMessages_andsqlStates_.
-
getSqlErrp
public java.lang.String getSqlErrp()
-
getSqlErrd
private int[] getSqlErrd()
-
formatSqlErrd
java.lang.String formatSqlErrd()
-
getSqlWarn
public java.lang.String getSqlWarn()
-
getSqlState
public java.lang.String getSqlState()
-
getSqlState
java.lang.String getSqlState(int messageNumber)
Get the SQL state for a given error.- Parameters:
messageNumber- the error to retrieve SQL state for- Returns:
- SQL state for the error
-
getArgs
public java.lang.Object[] getArgs(int messageNumber)
-
getMessage
private java.lang.String getMessage(int messageNumber) throws SqlException- Throws:
SqlException
-
getJDBCMessage
java.lang.String getJDBCMessage(int messageNumber)
-
getUnformattedMessage
private java.lang.String getUnformattedMessage(int messageNumber)
Get the unformatted message text (in case we cannot ask the server).- Parameters:
messageNumber- which message number to get the text for- Returns:
- string with details about the error
-
chainDeferredExceptionsToAgentOrAsConnectionWarnings
private void chainDeferredExceptionsToAgentOrAsConnectionWarnings(SqlException e)
-
getDataTruncation
java.sql.DataTruncation getDataTruncation()
Get ajava.sql.DataTruncationwarning based on the information in this SQLCA.- Returns:
- a
java.sql.DataTruncationinstance
-
processSqlErrmcTokens
private void processSqlErrmcTokens(byte[] tokenBytes)
-
bytes2String
protected java.lang.String bytes2String(byte[] bytes, int offset, int length)
-
getUpdateCount
public long getUpdateCount()
-
getRowCount
public long getRowCount() throws DisconnectException- Throws:
DisconnectException
-
setContainsSqlcax
public void setContainsSqlcax(boolean containsSqlcax)
-
containsSqlcax
public boolean containsSqlcax()
-
resetRowsetSqlca
public void resetRowsetSqlca(ClientConnection connection, int sqlCode, java.lang.String sqlState)
-
setRowsetRowCount
public void setRowsetRowCount(long rowCount)
-
getRowsetRowCount
public long getRowsetRowCount()
-
-