1 23 24 29 30 package com.sun.enterprise.admin.monitor.callflow; 31 import java.sql.BatchUpdateException ; 32 import java.sql.Connection ; 33 import com.sun.enterprise.admin.monitor.callflow.TableInfo; 34 import java.sql.SQLException ; 35 import java.util.logging.Level ; 36 import java.util.logging.Logger ; 37 import com.sun.enterprise.admin.common.constant.AdminConstants; 38 42 public class RequestEndAccessObjectImpl extends AbstractTableAccessObject{ 43 private static final Logger logger = 44 Logger.getLogger(AdminConstants.kLoggerName); 45 46 private static RequestEndAccessObjectImpl _singletonRE; 47 48 49 private RequestEndAccessObjectImpl() { 50 String serverName = super.getServerInstanceName(); 51 super.tableName = TableInfo.REQUEST_END_TABLE_NAME + 52 serverName.toUpperCase(); 53 } 54 55 public boolean dropTable(Connection connection) { 56 super.con = connection; 57 return super.createStatmentAndExecuteUpdate( 58 TableInfo.DROP_TABLE_REQUEST_END_SQL, 59 TableInfo.REQUEST_END_TABLE_NAME); 60 } 61 public boolean createTable (Connection connection){ 62 super.con = connection; 63 return super.createTable( 64 TableInfo.CREATE_TABLE_REQUEST_END_SQL, 65 TableInfo.REQUEST_END_TABLE_NAME); 66 } 67 68 public static TableAccessObject getInstance() { 69 if(_singletonRE == null) 70 _singletonRE = new RequestEndAccessObjectImpl (); 71 72 return _singletonRE; 73 } 74 75 public boolean insert(java.sql.PreparedStatement pstmt, TransferObject[] transferObject) { 76 if (pstmt == null) 78 return false; 79 80 boolean result = false; 81 try{ 82 for (int i = 0 ; i<transferObject.length; i++) { 83 RequestEndTO request = (RequestEndTO)transferObject[i]; 84 pstmt.setString(1, request.getRequestId()); 85 pstmt.setLong(2, request.getTimeStamp()); 86 pstmt.addBatch(); 87 } 88 int[] updated = pstmt.executeBatch(); 89 result = (updated.length == transferObject.length)? true : false; 90 } catch(BatchUpdateException bue) { 91 logger.log(Level.FINE, "Error inserting data into CallFlow tables", bue); 93 result = false; 94 }catch (SQLException se) { 95 logger.log(Level.FINE, "Error inserting data into CallFlow tables", se); 97 result = false; 98 } 99 return result; 100 } 101 102 public String getInsertSQL() { 103 String newsql = super.updateSqlWithTableName( 104 TableInfo.INSERT_INTO_TABLE_REQUEST_END_SQL, 105 TableInfo.REQUEST_END_TABLE_NAME); 106 return newsql; 107 } 108 109 public String getDeleteSQL () { 110 String newsql = super.updateSqlWithTableName ( 111 TableInfo.DELETE_FROM_TABLE_REQUEST_END_SQL, 112 TableInfo.REQUEST_END_TABLE_NAME); 113 return newsql; 114 } 115 116 117 } 118 | Popular Tags |