1 2 12 package com.versant.core.jdbc.logging; 13 14 import com.versant.core.logging.LogEvent; 15 import com.versant.core.logging.LogEvent; 16 17 20 public class JdbcLogEvent extends LogEvent { 21 22 protected int type; 23 protected String descr; 24 25 public static final int CON_OPEN = 0; 26 public static final int CON_CLOSE = 1; 27 public static final int CON_COMMIT = 2; 28 public static final int CON_ROLLBACK = 3; 29 public static final int CON_AUTOCOMMIT = 4; 30 public static final int CON_ISOLATION = 30; 31 public static final int CON_CREATE_STATEMENT = 5; 32 public static final int CON_PREPARE_STATEMENT = 6; 33 public static final int CON_PREPARE_CALL = 7; 34 35 public static final int STAT_EXEC_QUERY = 8; 36 public static final int STAT_EXEC_UPDATE = 9; 37 public static final int STAT_EXEC = 10; 38 public static final int STAT_CLOSE = 11; 39 public static final int STAT_ADD_BATCH = 12; 40 public static final int STAT_EXEC_BATCH = 13; 41 public static final int STAT_MAX_ROWS = 28; 42 43 public static final int RS_CLOSE = 14; 44 public static final int RS_NEXT = 15; 45 public static final int RS_RELATIVE = 16; 46 public static final int RS_ABSOLUTE = 17; 47 public static final int RS_LAST = 18; 48 public static final int RS_GET_ROW = 19; 49 public static final int RS_FETCH_SIZE = 20; 50 51 public static final int QUERY_COMPILE = 21; 52 53 public static final int POOL_ALLOC = 22; 54 public static final int POOL_RELEASE = 23; 55 public static final int POOL_BAD_CON = 24; 56 public static final int POOL_CON_FAILED= 25; 57 public static final int POOL_CON_TIMEOUT= 29; 58 public static final int POOL_CON_EXPIRED = 32; 59 public static final int POOL_FULL= 31; 60 61 public static final int PSPOOL_ALLOC = 26; 62 public static final int PSPOOL_RELEASE = 27; 63 64 public JdbcLogEvent(long txId, int type, String descr) { 65 this.datastoreTxId = txId; 66 this.type = type; 67 this.descr = descr; 68 } 69 70 73 public String getName() { 74 switch (type) { 75 case CON_OPEN: return "jdbc.con.connect"; 76 case CON_CLOSE: return "jdbc.con.close"; 77 case CON_COMMIT: return "jdbc.con.commit"; 78 case CON_ROLLBACK: return "jdbc.con.rollback"; 79 case CON_AUTOCOMMIT: return "jdbc.con.autoCommit"; 80 case CON_ISOLATION: return "jdbc.con.isolation"; 81 case CON_CREATE_STATEMENT: return "jdbc.con.createStat"; 82 case CON_PREPARE_STATEMENT: return "jdbc.con.prepareStat"; 83 case CON_PREPARE_CALL: return "jdbc.con.prepareCall"; 84 85 case STAT_EXEC_QUERY: return "jdbc.stat.execQuery"; 86 case STAT_EXEC_UPDATE: return "jdbc.stat.execUpdate"; 87 case STAT_EXEC: return "jdbc.stat.exec"; 88 case STAT_CLOSE: return "jdbc.stat.close"; 89 case STAT_ADD_BATCH: return "jdbc.stat.addBatch"; 90 case STAT_EXEC_BATCH: return "jdbc.stat.execBatch"; 91 case STAT_MAX_ROWS: return "jdbc.stat.maxrows"; 92 93 case RS_CLOSE: return "jdbc.rs.close"; 94 case RS_NEXT: return "jdbc.rs.next"; 95 case RS_RELATIVE: return "jdbc.rs.relative"; 96 case RS_ABSOLUTE: return "jdbc.rs.absolute"; 97 case RS_LAST: return "jdbc.rs.last"; 98 case RS_GET_ROW: return "jdbc.rs.getrow"; 99 case RS_FETCH_SIZE: return "jdbc.rs.fetchsize"; 100 101 case QUERY_COMPILE: return "jdbc.query.compile"; 102 103 case POOL_ALLOC: return "jdbc.pool.alloc"; 104 case POOL_RELEASE: return "jdbc.pool.release"; 105 case POOL_BAD_CON: return "jdbc.pool.badcon"; 106 case POOL_CON_FAILED: return "jdbc.pool.confailed"; 107 case POOL_CON_TIMEOUT: return "jdbc.pool.contimeout"; 108 case POOL_CON_EXPIRED: return "jdbc.pool.conexpired"; 109 case POOL_FULL: return "jdbc.pool.full"; 110 111 case PSPOOL_ALLOC: return "jdbc.pspool.alloc"; 112 case PSPOOL_RELEASE: return "jdbc.pspool.release"; 113 } 114 return "jdbc.UNKNOWN(" + type + ")"; 115 } 116 117 public String toString() { 118 String d = getDescription(); 119 if (d == null) { 120 return getName(); 121 } else { 122 StringBuffer s = new StringBuffer (); 123 s.append(getName()); 124 for (int n = 22 - s.length(); n > 0; n--) s.append(' '); 125 s.append(d); 126 return s.toString(); 127 } 128 } 129 130 public String getDescr() { 131 return descr; 132 } 133 134 public void setDescr(String descr) { 135 this.descr = descr; 136 } 137 138 141 public String getDescription() { 142 return descr; 143 } 144 145 public boolean isOwnTab() { 146 switch (type) { 147 case STAT_EXEC: 148 case STAT_EXEC_BATCH: 149 case STAT_EXEC_QUERY: 150 case STAT_EXEC_UPDATE: 151 return true; 152 } 153 return false; 154 } 155 156 159 public int getType() { 160 return type; 161 } 162 } 163 | Popular Tags |