01: //$Id: JDBCException.java 4626 2004-09-27 15:24:38Z oneovthafew $
02: package org.hibernate;
03:
04: import java.sql.SQLException;
05:
06: /**
07: * Wraps an <tt>SQLException</tt>. Indicates that an exception
08: * occurred during a JDBC call.
09: *
10: * @see java.sql.SQLException
11: * @author Gavin King
12: */
13: public class JDBCException extends HibernateException {
14:
15: private SQLException sqle;
16: private String sql;
17:
18: public JDBCException(String string, SQLException root) {
19: super (string, root);
20: sqle = root;
21: }
22:
23: public JDBCException(String string, SQLException root, String sql) {
24: this (string, root);
25: this .sql = sql;
26: }
27:
28: /**
29: * Get the SQLState of the underlying <tt>SQLException</tt>.
30: * @see java.sql.SQLException
31: * @return String
32: */
33: public String getSQLState() {
34: return sqle.getSQLState();
35: }
36:
37: /**
38: * Get the <tt>errorCode</tt> of the underlying <tt>SQLException</tt>.
39: * @see java.sql.SQLException
40: * @return int the error code
41: */
42: public int getErrorCode() {
43: return sqle.getErrorCode();
44: }
45:
46: /**
47: * Get the underlying <tt>SQLException</tt>.
48: * @return SQLException
49: */
50: public SQLException getSQLException() {
51: return sqle;
52: }
53:
54: /**
55: * Get the actual SQL statement that caused the exception
56: * (may be null)
57: */
58: public String getSQL() {
59: return sql;
60: }
61:
62: }
|