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 StartTimeAccessObjectImpl extends AbstractTableAccessObject{ 50 private static final Logger logger = 51 Logger.getLogger(AdminConstants.kLoggerName); 52 53 private static StartTimeAccessObjectImpl _singletonST; 54 55 56 private StartTimeAccessObjectImpl() { 57 String serverName = super.getServerInstanceName(); 58 super.tableName = TableInfo.START_TIME_TABLE_NAME + 59 serverName.toUpperCase(); 60 } 61 62 public static TableAccessObject getInstance() { 63 if(_singletonST == null) 64 _singletonST = new StartTimeAccessObjectImpl(); 65 return _singletonST; 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 StartTimeTO startTimeTO = (StartTimeTO)transferObject[i]; 76 pstmt.setString(1, startTimeTO.getRequestId()); 77 pstmt.setLong(2, startTimeTO.getTimeStamp()); 78 pstmt.setString( 79 3, startTimeTO.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_START_TIME_SQL, 100 TableInfo.START_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_START_TIME_SQL, 107 TableInfo.START_TIME_TABLE_NAME); 108 } 109 110 public String getInsertSQL() { 111 String newsql = super.updateSqlWithTableName( 112 TableInfo.INSERT_INTO_TABLE_START_TIME_SQL, 113 TableInfo.START_TIME_TABLE_NAME); 114 return newsql; 115 } 116 117 public String getDeleteSQL () { 118 String newsql = super.updateSqlWithTableName ( 119 TableInfo.DELETE_FROM_TABLE_START_TIME_SQL, 120 TableInfo.START_TIME_TABLE_NAME); 121 return newsql; 122 } 123 124 } 125 | Popular Tags |