KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > mdr > persistence > jdbcimpl > JdbcStorageException


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.mdr.persistence.jdbcimpl;
20
21 import org.netbeans.mdr.persistence.*;
22 import java.sql.*;
23 import java.io.*;
24
25 /**
26  * This is thrown to wrap an SQLException as a StorageException.
27  *
28  * @author John V. Sichi
29  * @version $Id: JdbcStorageException.java,v 1.3 2006/06/30 20:56:10 jtulach Exp $
30  *
31  * @see StorageIOException
32  */

33 public class JdbcStorageException extends StorageBadRequestException
34 {
35     /**
36      * The original SQLException that we are converting to a StorageException.
37      */

38     private SQLException sqlException;
39
40     /** this constructs a JdbcStorageException from an SQLException
41     * @param err the SQLException
42     */

43     public JdbcStorageException(SQLException err)
44     {
45         super(err.getMessage());
46         sqlException = err;
47     }
48
49     /** return the original SQLException's message */
50     public String JavaDoc getMessage()
51     {
52         return sqlException.getMessage();
53     }
54     
55     /** return the original SQLException's localized message */
56     public String JavaDoc getLocalizedMessage()
57     {
58         return sqlException.getLocalizedMessage();
59     }
60
61     /** print the original SQLException's stack trace */
62     public void printStackTrace()
63     {
64         sqlException.printStackTrace();
65     }
66
67     /** print the original SQLException's stack trace */
68     public void printStackTrace(PrintStream ps)
69     {
70         sqlException.printStackTrace(ps);
71     }
72
73     /** print the original SQLException's stack trace */
74     public void printStackTrace(PrintWriter pw)
75     {
76         sqlException.printStackTrace(pw);
77     }
78
79     /** get the original SQLException's cause */
80     public Throwable JavaDoc getCause()
81     {
82         return sqlException.getNextException();
83     }
84 }
85
86 // End JdbcStorageException.java
87
Popular Tags