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 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 MethodStartAccessObjectImpl extends AbstractTableAccessObject{ 43 private static final Logger logger = 44 Logger.getLogger(AdminConstants.kLoggerName); 45 46 private static MethodStartAccessObjectImpl _singletonMS; 47 48 49 private MethodStartAccessObjectImpl() { 50 String serverName = super.getServerInstanceName(); 51 super.tableName = TableInfo.METHOD_START_TABLE_NAME + 52 serverName.toUpperCase(); 53 } 54 55 public boolean createTable(Connection connection) { 56 super.con = connection; 57 return super.createTable( 58 TableInfo.CREATE_TABLE_METHOD_START_SQL, 59 TableInfo.METHOD_START_TABLE_NAME); 60 } 61 62 public boolean dropTable(Connection connection) { 63 super.con = connection; 64 return super.createStatmentAndExecuteUpdate( 65 TableInfo.DROP_TABLE_METHOD_START_SQL, 66 TableInfo.METHOD_START_TABLE_NAME); 67 } 68 69 public static TableAccessObject getInstance() { 70 if(_singletonMS == null) 71 _singletonMS = new MethodStartAccessObjectImpl (); 72 73 return _singletonMS; 74 } 75 76 public boolean insert(java.sql.PreparedStatement pstmt, TransferObject[] transferObject) { 77 if (pstmt == null) 79 return false; 80 boolean result = false; 81 try{ 82 83 for (int i = 0 ; i<transferObject.length; i++) { 84 MethodStartTO methodStartTO = (MethodStartTO)transferObject[i]; 85 pstmt.setString(1, methodStartTO.getRequestId()); 86 pstmt.setLong(2, methodStartTO.getTimeStamp()); 87 88 if (methodStartTO.getComponentType() != null) 89 pstmt.setString(3, methodStartTO.getComponentType().toString()); 90 else 91 pstmt.setString(3, null); 92 93 pstmt.setString(4, methodStartTO.getComponentName()); 94 pstmt.setString(5, methodStartTO.getAppName()); 95 pstmt.setString(6, methodStartTO.getMethodName()); 96 97 pstmt.setString(7, methodStartTO.getModuleName()); 98 pstmt.setString(8, methodStartTO.getThreadId()); 99 pstmt.setString(9, methodStartTO.getTransactionId()); 100 101 pstmt.setString(10, methodStartTO.getSecurityId()); 102 pstmt.addBatch(); 103 } 104 int[] updated = pstmt.executeBatch(); 105 result = (updated.length == transferObject.length)? true : false; 106 } catch(BatchUpdateException bue) { 107 logger.log(Level.FINE, "Error inserting data into CallFlow tables", bue); 109 result = false; 110 }catch (SQLException se) { 111 logger.log(Level.FINE, "Error inserting data into CallFlow tables", se); 113 result = false; 114 } 115 return result; } 116 117 public String getInsertSQL() { 118 String newsql = super.updateSqlWithTableName( 119 TableInfo.INSERT_INTO_TABLE_METHOD_START_SQL, 120 TableInfo.METHOD_START_TABLE_NAME); 121 return newsql; 122 } 123 124 public String getDeleteSQL () { 125 String newsql = super.updateSqlWithTableName ( 126 TableInfo.DELETE_FROM_TABLE_METHOD_START_SQL, 127 TableInfo.METHOD_START_TABLE_NAME); 128 return newsql; 129 } 130 131 } 132 | Popular Tags |