Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

JetWebDBException.java

Go to the documentation of this file.
00001 package cedar.jetweb.db;
00002 
00003 import cedar.jetweb.JetWebException;
00004 
00005 import java.io.PrintStream;
00006 import java.io.PrintWriter;
00007 
00008 import java.sql.SQLException;
00009 
00010 
00019 public class JetWebDBException extends JetWebException {
00020     private String sql = "";
00021 
00022     //    private String data = "";
00023 
00031     public JetWebDBException(SQLException originalException, String sql, String data) {
00032         super(originalException);
00033         this.sql = sql;
00034         this.data = data;
00035     }
00036 
00043     public JetWebDBException(String message, String data) {
00044         super(message, data);
00045     }
00046 
00053     public String getMessage() {
00054         StringBuffer b = new StringBuffer();
00055 
00056         if (getOriginalException() == null) {
00057             b.append(super.getMessage());
00058         } else {
00059             b.append(((SQLException) getOriginalException()).getMessage());
00060             b.append("\n:SQL:");
00061             b.append(sql);
00062             b.append("\n:CODE:");
00063             b.append(((SQLException) getOriginalException()).getErrorCode());
00064             b.append("\n:STATE:");
00065             b.append(((SQLException) getOriginalException()).getSQLState());
00066         }
00067 
00068         if (data != "") {
00069             b.append("\n:DATA:");
00070             b.append(data);
00071         }
00072 
00073         return b.toString();
00074     }
00075 }

Generated Wed Jan 17 09:14:27 GMT 2007