1 24 25 package com.mckoi.database; 26 27 import java.util.ArrayList ; 28 29 38 39 final class GTConnectionInfoDataSource extends GTDataSource { 40 41 45 private DatabaseConnection database; 46 47 50 private ArrayList key_value_pairs; 51 52 55 public GTConnectionInfoDataSource(DatabaseConnection connection) { 56 super(connection.getSystem()); 57 this.database = connection; 58 this.key_value_pairs = new ArrayList (); 59 } 60 61 64 public GTConnectionInfoDataSource init() { 65 66 key_value_pairs.add("auto_commit"); 68 key_value_pairs.add(database.getAutoCommit() ? "true" : "false"); 69 70 key_value_pairs.add("isolation_level"); 71 key_value_pairs.add(database.getTransactionIsolationAsString()); 72 73 key_value_pairs.add("user"); 74 key_value_pairs.add(database.getUser().getUserName()); 75 76 key_value_pairs.add("time_connection"); 77 key_value_pairs.add(new java.sql.Timestamp ( 78 database.getUser().getTimeConnected()).toString()); 79 80 key_value_pairs.add("connection_string"); 81 key_value_pairs.add(database.getUser().getConnectionString()); 82 83 key_value_pairs.add("current_schema"); 84 key_value_pairs.add(database.getCurrentSchema()); 85 86 key_value_pairs.add("case_insensitive_identifiers"); 87 key_value_pairs.add(database.isInCaseInsensitiveMode() ? "true" : "false"); 88 89 return this; 90 } 91 92 94 public DataTableDef getDataTableDef() { 95 return DEF_DATA_TABLE_DEF; 96 } 97 98 public int getRowCount() { 99 return key_value_pairs.size() / 2; 100 } 101 102 public TObject getCellContents(final int column, final int row) { 103 switch (column) { 104 case 0: return columnValue(column, (String ) key_value_pairs.get(row * 2)); 106 case 1: return columnValue(column, 108 (String ) key_value_pairs.get((row * 2) + 1)); 109 default: 110 throw new Error ("Column out of bounds."); 111 } 112 } 113 114 116 public void dispose() { 117 super.dispose(); 118 key_value_pairs = null; 119 database = null; 120 } 121 122 124 127 static final DataTableDef DEF_DATA_TABLE_DEF; 128 129 static { 130 131 DataTableDef def = new DataTableDef(); 132 def.setTableName( 133 new TableName(Database.SYSTEM_SCHEMA, "sUSRConnectionInfo")); 134 135 def.addColumn(stringColumn("var")); 137 def.addColumn(stringColumn("value")); 138 139 def.setImmutable(); 141 142 DEF_DATA_TABLE_DEF = def; 143 144 } 145 146 } 147 | Popular Tags |