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