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 com.sun.enterprise.admin.monitor.callflow.AbstractTableAccessObject; 35 import java.sql.SQLException ; 36 import java.util.logging.Level ; 37 import java.util.logging.Logger ; 38 import com.sun.enterprise.admin.common.constant.AdminConstants; 39 43 public class MethodEndAccessObjectImpl extends AbstractTableAccessObject{ 44 private static final Logger logger = 45 Logger.getLogger(AdminConstants.kLoggerName); 46 47 private static MethodEndAccessObjectImpl _singletonME; 48 49 52 private MethodEndAccessObjectImpl() { 53 String serverName = super.getServerInstanceName(); 54 super.tableName = TableInfo.METHOD_END_TABLE_NAME + 55 serverName.toUpperCase(); 56 } 57 58 public boolean dropTable(Connection connection) { 59 super.con = connection; 60 return super.createStatmentAndExecuteUpdate( 61 TableInfo.DROP_TABLE_METHOD_END_SQL, 62 TableInfo.METHOD_END_TABLE_NAME); 63 } 64 65 public boolean createTable(Connection connection) { 66 super.con = connection; 67 return super.createTable( 68 TableInfo.CREATE_TABLE_METHOD_END_SQL, 69 TableInfo.METHOD_END_TABLE_NAME); 70 71 } 72 73 public static TableAccessObject getInstance() { 74 if(_singletonME == null) 75 _singletonME = new MethodEndAccessObjectImpl(); 76 77 return _singletonME; 78 } 79 80 public boolean insert(java.sql.PreparedStatement pstmt, TransferObject[] transferObject) { 81 if (pstmt == null) 83 return false; 84 boolean result = false; 85 try{ 86 87 for (int i = 0 ; i<transferObject.length; i++) { 88 MethodEndTO methodEndTO = (MethodEndTO)transferObject[i]; 89 pstmt.setString(1, methodEndTO.getRequestId()); 90 pstmt.setLong(2, methodEndTO.getTimeStamp()); 91 pstmt.setString(3, methodEndTO.getException()); 92 pstmt.addBatch(); 93 94 } 95 int[] updated = pstmt.executeBatch(); 96 result = (updated.length == transferObject.length)? true : false; 97 } catch(BatchUpdateException bue) { 98 logger.log(Level.FINE, "Error inserting data into CallFlow tables", bue); 100 result = false; 101 }catch (SQLException se) { 102 logger.log(Level.FINE, "Error inserting data into CallFlow tables", se); 104 result = false; 105 } 106 return result; 107 } 108 109 public String getInsertSQL() { 110 String newsql = super.updateSqlWithTableName( 111 TableInfo.INSERT_INTO_TABLE_METHOD_END_SQL, 112 TableInfo.METHOD_END_TABLE_NAME); 113 return newsql; 114 } 115 116 public String getDeleteSQL () { 117 String newsql = super.updateSqlWithTableName ( 118 TableInfo.DELETE_FROM_TABLE_METHOD_END_SQL, 119 TableInfo.METHOD_END_TABLE_NAME); 120 return newsql; 121 } 122 123 } 124 | Popular Tags |