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 java.sql.PreparedStatement ; 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 44 public class RequestStartAccessObjectImpl extends AbstractTableAccessObject{ 45 private static final Logger logger = 46 Logger.getLogger(AdminConstants.kLoggerName); 47 48 private static RequestStartAccessObjectImpl _singletonRS; 49 50 53 private RequestStartAccessObjectImpl() { 54 String serverName = super.getServerInstanceName(); 55 super.tableName = TableInfo.REQUEST_START_TABLE_NAME + 56 serverName.toUpperCase(); 57 } 58 59 public String getInsertSQL () { 60 String newsql = super.updateSqlWithTableName( 61 TableInfo.INSERT_INTO_TABLE_REQUEST_START_SQL, 62 TableInfo.REQUEST_START_TABLE_NAME); 63 return newsql; 64 } 65 66 public String getDeleteSQL () { 67 String newsql = super.updateSqlWithTableName ( 68 TableInfo.DELETE_FROM_TABLE_REQUEST_START_SQL, 69 TableInfo.REQUEST_START_TABLE_NAME); 70 return newsql; 71 } 72 73 public boolean dropTable(Connection connection) { 74 super.con = connection; 75 return super.createStatmentAndExecuteUpdate(TableInfo. 76 DROP_TABLE_REQUEST_START_SQL, TableInfo.REQUEST_START_TABLE_NAME); 77 78 79 } 80 81 public boolean createTable (Connection connection){ 82 super.con = connection; 83 return super.createTable(TableInfo. 84 CREATE_TABLE_REQUEST_START_SQL, TableInfo.REQUEST_START_TABLE_NAME); 85 86 } 87 88 89 public static TableAccessObject getInstance() { 90 if(_singletonRS == null) 91 _singletonRS = new RequestStartAccessObjectImpl (); 92 93 return _singletonRS; 94 } 95 96 public boolean insert(PreparedStatement pstmt, TransferObject[] requestStart) { 97 if (pstmt == null) 99 return false; 100 101 boolean result = false; 102 try{ 103 for (int i = 0 ; i<requestStart.length; i++) { 104 RequestStartTO request = (RequestStartTO)requestStart[i]; 105 pstmt.setString(1, request.getRequestId()); 106 pstmt.setLong(2, request.getTimeStamp()); 107 pstmt.setLong (3, request.getTimeStampMillis()); 108 if(request.getRequestType() != null) 109 pstmt.setString(4, request.getRequestType().toString()); 110 else 111 pstmt.setString(4, null); 112 if (request.getIpAddress() != null) 113 pstmt.setString(5, request.getIpAddress()); 114 else 115 pstmt.setString (5, null); 116 117 pstmt.addBatch(); 118 } 119 int[] updated = pstmt.executeBatch(); 120 result = (updated.length == requestStart.length)? true : false; 121 if (result == false){ 122 logger.log(Level.WARNING, "callflow.error_insert_row"); 123 } 124 } catch(BatchUpdateException bue) { 125 logger.log(Level.FINE, "Error inserting data into CallFlow tables", bue); 127 result = false; 128 }catch (SQLException se) { 129 logger.log(Level.FINE, "Error inserting data into CallFlow tables", se); 131 result = false; 132 } 133 return result; 134 } 135 136 137 } 138 | Popular Tags |