KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > db > OracleErrorAnalyzer


1 package com.teamkonzept.db;
2
3 import java.sql.SQLException JavaDoc;
4 import com.teamkonzept.lib.*;
5
6 /**
7     Analyzed database related exceptions
8     using the SQL State
9     here some Oracle specific extensions
10     * @author $Author: alex $
11     * @version $Revision: 1.2 $
12 */

13 public class OracleErrorAnalyzer extends DatabaseErrorAnalyzer
14 {
15     protected OracleErrorAnalyzer()
16     {}
17     
18     
19     // alle Fälle nochmal mit anderen Treibern/Datenbanken testen !!
20
public TKException analyzeSQLError(SQLException JavaDoc e)
21     {
22         String JavaDoc state = e.getSQLState();
23         // System.out.println("Oracle State : " + state);
24
if (state == null)
25         {
26             return new TKDatabaseException("Unbekannter Fehler",UNDEFINED, NORMAL_SEVERITY, false, e);
27         }
28
29         // Wrong URL format.
30
if (state.equals("JZ003"))
31         {
32             return new TKDatabaseException("Ihre Konfiguration ist inkorrekt",CONFIGURATION, HIGH_SEVERITY , true, e);
33         }
34
35         // Host unreachable.
36
if (state.equals("JZ006"))
37         {
38             // das kann aber auch Konfiguration sein ! falsche Portnummer
39
return new TKDatabaseException("Die Datenbank ist nicht erreichbar",CONNECTION_BROKEN, TEMPORARY_SEVERITY , true, e);
40         }
41
42         // Login failed.
43
if (state.equals("ORA-01005") || state.equals("ORA-01004") || state.equals("ORA-01017"))
44         {
45             return new TKDatabaseException("Ihre Konfiguration ist inkorrekt",CONFIGURATION, HIGH_SEVERITY , true, e);
46         }
47         // too many open cursors
48
if (state.equals("ORA-01000"))
49         {
50             return new TKDatabaseException("Zu viele offene Cursor", TOO_MANY_CURSOR, HIGH_SEVERITY, false, e);
51         }
52         
53         // JDBC-Support not loaded.
54
if (state.equals("JZ0SJ"))
55         {
56             return new TKDatabaseException("Keine JDBC-Unterstützung in der DB installiert", CONFIGURATION, HIGH_SEVERITY, true, e);
57         }
58
59         // Foreign key constraint violation.
60
if (state.equals("23000") || state.equals("23001"))
61         {
62             return new TKDatabaseException("Referentielle Integrität verletzt",FK_CONSTRAINT_VIOLATION, NORMAL_SEVERITY , true, e);
63         }
64         return new TKDatabaseException("Unbekannter Fehler",UNDEFINED, NORMAL_SEVERITY, false, e);
65     }
66 }
Popular Tags