Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.common.exceptions.SQLExceptionFactory Class Reference

List of all members.

Static Public Member Functions

SQLException getSQLException (SQLException sqlEx, String cjdbcMessage)
SQLException getSQLException (List exceptions, String cjdbcMessage)

Detailed Description

This class defines a SQLExceptionFactory

Author:
Marc Wick
Version:
1.0

Definition at line 36 of file SQLExceptionFactory.java.


Member Function Documentation

SQLException org.objectweb.cjdbc.common.exceptions.SQLExceptionFactory.getSQLException List  exceptions,
String  cjdbcMessage
[static]
 

creates a new SQLException with the cjdbcMessage, if all exceptions in the list have the same errorcode and sqlstate the returned SQLExcepion will be constructed with this values otherwise with null and 0

Parameters:
exceptions list of exceptions
cjdbcMessage the cjdbc message
Returns:
a new SQLException

Definition at line 64 of file SQLExceptionFactory.java.

00066   {
00067     String sqlState = null;
00068     int errorCode = 0;
00069     for (int i = 0; i < exceptions.size(); i++)
00070     {
00071       SQLException ex = (SQLException) exceptions.get(i);
00072       cjdbcMessage += ex.getMessage() + "\n";
00073       if (i == 0)
00074       {
00075         //first exception
00076         sqlState = ex.getSQLState();
00077         errorCode = ex.getErrorCode();
00078       }
00079       else
00080       {
00081         //make sure sqlState is the same for all backends
00082         if (sqlState != null && !sqlState.equals(ex.getSQLState()))
00083           sqlState = null;
00084         //make sure the error code is the same for all backends
00085         if (errorCode != ex.getErrorCode())
00086           errorCode = 0;
00087       }
00088     }
00089     return new SQLException(cjdbcMessage, sqlState, errorCode);
00090   }

SQLException org.objectweb.cjdbc.common.exceptions.SQLExceptionFactory.getSQLException SQLException  sqlEx,
String  cjdbcMessage
[static]
 

creates a new SQLException with the cjdbcMessage

Parameters:
sqlEx the original exception
cjdbcMessage the cjdbc message to use for the new sqlexception
Returns:
a new SQLException

Definition at line 46 of file SQLExceptionFactory.java.

00048   {
00049     SQLException newException = new SQLException(cjdbcMessage, sqlEx
00050         .getSQLState(), sqlEx.getErrorCode());
00051     newException.setNextException(sqlEx);
00052     return newException;
00053   }


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:01:40 2005 for C-JDBC by  doxygen 1.3.9.1