KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > DatabaseConstraintViolationException


1 /**
2  * com.mckoi.database.DatabaseConstraintViolationException 02 Sep 2001
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * Version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License Version 2 for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * Version 2 along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  * Change Log:
21  *
22  *
23  */

24
25 package com.mckoi.database;
26
27 /**
28  * A database exception that represents a constraint violation.
29  *
30  * @author Tobias Downer
31  */

32
33 public class DatabaseConstraintViolationException extends RuntimeException JavaDoc {
34
35   // ---------- Statics ----------
36

37   /**
38    * A Primary Key constraint violation error code.
39    */

40   public static final int PRIMARY_KEY_VIOLATION = 20;
41
42   /**
43    * A Unique constraint violation error code.
44    */

45   public static final int UNIQUE_VIOLATION = 21;
46
47   /**
48    * A Check constraint violation error code.
49    */

50   public static final int CHECK_VIOLATION = 22;
51
52   /**
53    * A Foreign Key constraint violation error code.
54    */

55   public static final int FOREIGN_KEY_VIOLATION = 23;
56
57   /**
58    * A Nullable constraint violation error code (data added to not null
59    * columns that was null).
60    */

61   public static final int NULLABLE_VIOLATION = 24;
62
63   /**
64    * Java type constraint violation error code (tried to insert a Java object
65    * that wasn't derived from the java object type defined for the column).
66    */

67   public static final int JAVA_TYPE_VIOLATION = 25;
68
69   /**
70    * Tried to drop a table that is referenced by another source.
71    */

72   public static final int DROP_TABLE_VIOLATION = 26;
73
74   /**
75    * Column can't be dropped before of an reference to it.
76    */

77   public static final int DROP_COLUMN_VIOLATION = 27;
78
79
80   /**
81    * The error code.
82    */

83   private int error_code;
84
85   /**
86    * Constructor.
87    */

88   public DatabaseConstraintViolationException(int err_code, String JavaDoc msg) {
89     super(msg);
90     this.error_code = err_code;
91   }
92
93   /**
94    * Returns the violation error code.
95    */

96   public int getErrorCode() {
97     return error_code;
98   }
99
100 }
101
Popular Tags