1 28 29 package ist.coach.coachEmfServicesComponents.BasicLogProviderComposition; 30 31 import java.sql.*; 32 38 public class BasicLogProviderImpl 39 extends ist.coach.coachEmfServicesComponents.BasicLogProviderComposition.BasicLogProvider_impl 40 { 41 private int recordsReadRange_; 47 private int logId_; 48 private int logMaxSize_; 49 private String databaseConnection_; 50 private String databaseTable_; 51 private String databaseDriver_; 52 private short logFullAction_; 53 private String databaseUserData_ = "?user=test1&password=test1"; 54 private String display_name_; 55 56 62 public BasicLogProviderImpl() 63 { 64 } 65 66 public BasicLogProviderImpl(int logId) 67 { 68 if (logId > 0) 69 logId_ = logId; 70 } 71 85 public void 86 configuration_complete() 87 throws org.omg.Components.InvalidConfiguration 88 { 89 90 94 org.omg.CORBA.ORB orb = 95 org.objectweb.ccm.CORBA.TheORB.getORB(); 96 97 if (logId() == 0) 98 throw new org.omg.Components.InvalidConfiguration(); 99 100 String logIDstr = Integer.toString(logId()); 101 logIDstr = databaseTable() + logIDstr; 102 103 try { 112 Class.forName(databaseDriver()).newInstance(); 113 } 114 catch (Exception ex) { 115 System.err.println("** BasicLogImpl: <EXCEPTION> While connecting to jdbc driver"); 116 System.err.println(ex.getMessage()); 117 118 } 119 120 Connection dbConnection = null; 121 try { 122 dbConnection = DriverManager.getConnection(databaseConnection()); 123 Statement dbStatement = dbConnection.createStatement(); 124 String sqlStr = "CREATE TABLE " + logIDstr + 125 "(logRecordId BIGINT PRIMARY KEY, " + 126 "timeStamp VARCHAR(30), " + 127 "logDataType TINYINT, " + 128 "logData BLOB)"; 129 130 boolean logCreatedInDb = dbStatement.execute(sqlStr); 131 } 132 catch (SQLException ex) { 133 System.err.println(logIDstr + " Table propably already exists in the database..."); 134 } 138 System.err.println("LogProvider " + display_name() + " configuration completed..."); 139 } 140 141 151 public void 152 ccm_remove() 153 throws org.omg.Components.CCMException 154 { 155 173 } 174 182 public int 183 recordsReadRange() 184 { 185 return recordsReadRange_; 189 } 190 193 public void 194 recordsReadRange(int val) 195 { 196 if (val > 0) 200 recordsReadRange_ = val; 201 } 203 204 207 public short 208 logFullAction() 209 { 210 return logFullAction_; 214 } 215 218 public void 219 logFullAction(short val) 220 { 221 if (val > 0) 225 logFullAction_ = val; 226 } 228 231 public int 232 logMaxSize() 233 { 234 return logMaxSize_; 238 } 239 242 public void 243 logMaxSize(int val) 244 { 245 if (val > 0) 249 logMaxSize_ = val; 250 } 252 253 public void logId(int val) { 254 if (val > 0) 255 logId_ = val; 256 257 259 260 261 } 262 263 public int logId() { 264 return logId_; 265 } 266 269 public void 270 databaseConnection(String val) 271 { 272 if (val != null && val.length() > 0) 276 databaseConnection_ = val + databaseUserData_; 277 } 279 282 public String 283 databaseConnection() 284 { 285 return databaseConnection_; 289 } 290 291 294 public void 295 databaseDriver(String val) 296 { 297 if (val != null && val.length() > 0) 301 databaseDriver_ = val; 302 } 304 307 public String 308 databaseDriver() 309 { 310 return databaseDriver_; 314 } 315 316 319 public void 320 databaseTable(String val) 321 { 322 if (val != null && val.length() > 0) 326 databaseTable_ = val; 327 } 329 332 public String 333 databaseTable() 334 { 335 return databaseTable_; 339 } 340 343 public void 344 display_name(String val) 345 { 346 if (val != null && val.length() > 0) 350 display_name_ = val; 351 352 } 353 354 public String 355 display_name() 356 { 357 return display_name_; 361 } 362 } 363 | Popular Tags |