KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > exceptions > database > JahiaDatabaseException


1 /*
2  * ____.
3  * __/\ ______| |__/\. _______
4  * __ .____| | \ | +----+ \
5  * _______| /--| | | - \ _ | : - \_________
6  * \\______: :---| : : | : | \________>
7  * |__\---\_____________:______: :____|____:_____\
8  * /_____|
9  *
10  * . . . i n j a h i a w e t r u s t . . .
11  *
12  *
13  *
14  * ----- BEGIN LICENSE BLOCK -----
15  * Version: JCSL 1.0
16  *
17  * The contents of this file are subject to the Jahia Community Source License
18  * 1.0 or later (the "License"); you may not use this file except in
19  * compliance with the License. You may obtain a copy of the License at
20  * http://www.jahia.org/license
21  *
22  * Software distributed under the License is distributed on an "AS IS" basis,
23  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
24  * for the rights, obligations and limitations governing use of the contents
25  * of the file. The Original and Upgraded Code is the Jahia CMS and Portal
26  * Server. The developer of the Original and Upgraded Code is JAHIA Ltd. JAHIA
27  * Ltd. owns the copyrights in the portions it created. All Rights Reserved.
28  *
29  * The Developer of the Shared Modifications is Jahia Solution Sarl.
30  * Portions created by the Initial Developer are Copyright (C) 2002 by the
31  * Initial Developer. All Rights Reserved.
32  *
33  * Contributor(s):
34  * 29-MAR-2001, Jahia Solutions Sarl, Fulco Houkes : Initial version
35  * 29-JUL-2003, Jahia Solutions Sarl, Fulco Houkes
36  * 15-SEP-2003, Jahia Solutions Sarl, Fulco Houkes
37  *
38  * ----- END LICENSE BLOCK -----
39  */

40
41 package org.jahia.exceptions.database;
42
43 import java.sql.SQLException JavaDoc;
44
45 import org.jahia.exceptions.JahiaPersistenceException;
46
47
48 /** This exception is used to raise a database exception.
49  *
50  * @author Fulco Houkes
51  * @version 1.1
52  * @since Jahia 1.0
53  */

54 public class JahiaDatabaseException extends JahiaPersistenceException {
55
56     /** The <code>SQLException</code> reference that generated this exception. */
57     private SQLException JavaDoc sqlException = null;
58
59     /** The SQL query associated to the this exception. */
60     private String JavaDoc query = null;
61
62
63
64     /**
65      * Default constructor.
66      *
67      * @param message
68      * Error message displayed only in the Jahia console.
69      * @param query
70      * String representing the query that generated the error.
71      * @param ex
72      * The SQL exception associated with the exception.
73      * <b>MUST BE NON-NULL!</b>
74      * @param severity
75      * Severity code.
76      */

77     public JahiaDatabaseException (String JavaDoc message, String JavaDoc query,
78                                    SQLException JavaDoc ex, int severity) {
79         super ("Database: " + message + " while excuting query [" + query +
80                 "]\n SQLException : " + ex.getMessage (), DATABASE_ERROR, severity, ex);
81         sqlException = ex;
82         this.query = query;
83     }
84
85
86     /**
87      * Default constructor.
88      *
89      * @param message
90      * Error message displayed only in the Jahia console.
91      * @param ex
92      * The SQL exception associated with the exception.
93      * <b>MUST BE NON-NULL!</b>
94      * @param severity
95      * Severity code.
96      */

97     public JahiaDatabaseException (String JavaDoc message, SQLException JavaDoc ex,
98                                    int severity) {
99         super ("Database: " + message + "\n SQLException : " + ex.getMessage (),
100                 DATABASE_ERROR, severity, ex);
101         sqlException = ex;
102     }
103
104
105     /**
106      * Instanciate a <code>JahiaDatabaseException</code>.
107      *
108      * @param message
109      * Error message displayed only in the Jahia console.
110      * @param query
111      * String representing the query that generated the error.
112      * @param severity
113      * Severity code.
114      */

115     public JahiaDatabaseException (String JavaDoc message, String JavaDoc query, int severity) {
116         super ("Database: " + message + " while executing query [" + query + "]",
117                 DATABASE_ERROR, severity);
118         this.query = query;
119     }
120
121
122     /**
123      * Instanciate a <code>JahiaDatabaseException</code>.
124      *
125      * @param message
126      * Error message displayed only in the Jahia console.
127      * @param severity
128      * Severity code.
129      */

130     public JahiaDatabaseException (String JavaDoc message, int severity) {
131         super ("Database: " + message, DATABASE_ERROR, severity);
132     }
133
134
135     /**
136      * Return the reference on the SQL exception. If no SQL exception occured,
137      * this method return <code>null</code>.
138      *
139      * @return
140      * Return the SQL exception reference, or <code>null</code> if no
141      * SQL exception
142      */

143     final public SQLException JavaDoc getSQLException () {
144         return sqlException;
145     }
146
147
148     /**
149      * Return the query that generated the exception. If the exception source
150      * is not due to a query execution, null is returned.
151      *
152      * @return
153      * Return the query, or null if the exception was not generated after
154      * a query execution.
155      */

156     final public String JavaDoc getQuery () {
157         return query;
158     }
159
160 }
161
Popular Tags