1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package java.sql;
19
20/**
21 * An exception, which is subclass of SQLNonTransientException, is thrown when
22 * various the an integrity constraint (foreign key, primary key or unique key)
23 * has been violated.
24 */
25public class SQLIntegrityConstraintViolationException extends
26        SQLNonTransientException {
27
28    private static final long serialVersionUID = 8033405298774849169L;
29
30    /**
31     * Creates an SQLIntegrityConstraintViolationException object. The Reason
32     * string is set to null, the SQLState string is set to null and the Error
33     * Code is set to 0.
34     */
35    public SQLIntegrityConstraintViolationException() {
36    }
37
38    /**
39     * Creates an SQLIntegrityConstraintViolationException object. The Reason
40     * string is set to the given reason string, the SQLState string is set to
41     * null and the Error Code is set to 0.
42     *
43     * @param reason
44     *            the string to use as the Reason string
45     */
46    public SQLIntegrityConstraintViolationException(String reason) {
47        super(reason, null, 0);
48    }
49
50    /**
51     * Creates an SQLIntegrityConstraintViolationException object. The Reason
52     * string is set to the given reason string, the SQLState string is set to
53     * the given SQLState string and the Error Code is set to 0.
54     *
55     * @param reason
56     *            the string to use as the Reason string
57     * @param sqlState
58     *            the string to use as the SQLState string
59     */
60    public SQLIntegrityConstraintViolationException(String reason,
61            String sqlState) {
62        super(reason, sqlState, 0);
63    }
64
65    /**
66     * Creates an SQLIntegrityConstraintViolationException object. The Reason
67     * string is set to the given reason string, the SQLState string is set to
68     * the given SQLState string and the Error Code is set to the given error
69     * code value.
70     *
71     * @param reason
72     *            the string to use as the Reason string
73     * @param sqlState
74     *            the string to use as the SQLState string
75     * @param vendorCode
76     *            the integer value for the error code
77     */
78    public SQLIntegrityConstraintViolationException(String reason,
79            String sqlState, int vendorCode) {
80        super(reason, sqlState, vendorCode);
81    }
82
83    /**
84     * Creates an SQLIntegrityConstraintViolationException object. The Reason
85     * string is set to the null if cause == null or cause.toString() if
86     * cause!=null,and the cause Throwable object is set to the given cause
87     * Throwable object.
88     *
89     * @param cause
90     *            the Throwable object for the underlying reason this
91     *            SQLException
92     */
93    public SQLIntegrityConstraintViolationException(Throwable cause) {
94        super(cause);
95    }
96
97    /**
98     * Creates an SQLIntegrityConstraintViolationException object. The Reason
99     * string is set to the given and the cause Throwable object is set to the
100     * given cause Throwable object.
101     *
102     * @param reason
103     *            the string to use as the Reason string
104     * @param cause
105     *            the Throwable object for the underlying reason this
106     *            SQLException
107     */
108    public SQLIntegrityConstraintViolationException(String reason,
109            Throwable cause) {
110        super(reason, cause);
111    }
112
113    /**
114     * Creates an SQLIntegrityConstraintViolationException object. The Reason
115     * string is set to the given reason string, the SQLState string is set to
116     * the given SQLState string and the cause Throwable object is set to the
117     * given cause Throwable object.
118     *
119     * @param reason
120     *            the string to use as the Reason string
121     * @param sqlState
122     *            the string to use as the SQLState string
123     * @param cause
124     *            the Throwable object for the underlying reason this
125     *            SQLException
126     */
127    public SQLIntegrityConstraintViolationException(String reason,
128            String sqlState, Throwable cause) {
129        super(reason, sqlState, cause);
130    }
131
132    /**
133     * Creates an SQLIntegrityConstraintViolationException object. The Reason
134     * string is set to the given reason string, the SQLState string is set to
135     * the given SQLState string , the Error Code is set to the given error code
136     * value, and the cause Throwable object is set to the given cause Throwable
137     * object.
138     *
139     * @param reason
140     *            the string to use as the Reason string
141     * @param sqlState
142     *            the string to use as the SQLState string
143     * @param vendorCode
144     *            the integer value for the error code
145     * @param cause
146     *            the Throwable object for the underlying reason this
147     *            SQLException
148     */
149    public SQLIntegrityConstraintViolationException(String reason,
150            String sqlState, int vendorCode, Throwable cause) {
151        super(reason, sqlState, vendorCode, cause);
152    }
153}
154