KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > JDBCException


1 //$Id: JDBCException.java,v 1.5 2004/09/27 15:24:34 oneovthafew Exp $
2
package org.hibernate;
3
4 import java.sql.SQLException JavaDoc;
5
6
7 /**
8  * Wraps an <tt>SQLException</tt>. Indicates that an exception
9  * occurred during a JDBC call.
10  *
11  * @see java.sql.SQLException
12  * @author Gavin King
13  */

14 public class JDBCException extends HibernateException {
15
16     private SQLException JavaDoc sqle;
17     private String JavaDoc sql;
18
19     public JDBCException(String JavaDoc string, SQLException JavaDoc root) {
20         super(string, root);
21         sqle=root;
22     }
23
24     public JDBCException(String JavaDoc string, SQLException JavaDoc root, String JavaDoc sql) {
25         this(string, root);
26         this.sql = sql;
27     }
28
29     /**
30      * Get the SQLState of the underlying <tt>SQLException</tt>.
31      * @see java.sql.SQLException
32      * @return String
33      */

34     public String JavaDoc getSQLState() {
35         return sqle.getSQLState();
36     }
37
38     /**
39      * Get the <tt>errorCode</tt> of the underlying <tt>SQLException</tt>.
40      * @see java.sql.SQLException
41      * @return int the error code
42      */

43     public int getErrorCode() {
44         return sqle.getErrorCode();
45     }
46
47     /**
48      * Get the underlying <tt>SQLException</tt>.
49      * @return SQLException
50      */

51     public SQLException JavaDoc getSQLException() {
52         return sqle;
53     }
54     
55     /**
56      * Get the actual SQL statement that caused the exception
57      * (may be null)
58      */

59     public String JavaDoc getSQL() {
60         return sql;
61     }
62
63 }
64
Popular Tags