| 1 package in.co.daffodil.db.general; 2 3 import java.sql.*; 4 import com.daffodilwoods.database.resource.*; 5 import java.io.*; 6 import java.util.Date ; 7 import java.util.Locale ; 8 import com.daffodilwoods.daffodildb.server.serversystem._Server; 9 10 public class DaffodilDBExceptionHandler { 11 12 public static final void handle(String reason,String code,Exception exc,Locale locale)throws SQLException { 13 if(exc instanceof BatchUpdateException || exc instanceof SQLException) 14 throw (SQLException)exc; 15 if( exc instanceof DException ) 16 throw ((DException)exc).getSqlException(locale); 17 26 throw new in.co.daffodil.db.general.DaffodilDBExceptionWrapper(reason,exc); 27 } 28 29 public static final void handle(String reason,String code,Exception exc)throws SQLException { 30 if(exc instanceof BatchUpdateException || exc instanceof SQLException) 31 throw (SQLException)exc; 32 if( exc instanceof DException ) 33 throw ((DException)exc).getSqlException(null); 34 43 throw new in.co.daffodil.db.general.DaffodilDBExceptionWrapper(reason,exc); 44 } 45 46 static PrintWriter printWriter; 47 private static PrintWriter getLogWriter(){ 48 try { 49 if(printWriter == null){ 50 String fileName = System.getProperty(_Server.DAFFODILDB_HOME,"C:" +File.separator+ "DaffodilDaffodilDB"); 51 File f = new File(fileName); 52 if(!f.exists()) 53 f.mkdirs(); 54 fileName += File.separator+"ErrorLog.log"; 55 printWriter = new PrintWriter(new FileWriter(fileName,true)); 56 } 57 return printWriter; 58 }catch(Exception ex) { 59 return null; 60 } 61 } 62 63 64 public void finalize(){ 65 try { 66 if(printWriter!=null) { 67 printWriter.flush(); 68 printWriter.close(); 69 } 70 }catch(Exception e){ 71 } 72 } 73 74 } 75 | Popular Tags |