1 25 package org.jresearch.gossip.dao.drivers; 26 27 import java.util.ResourceBundle ; 28 29 35 public abstract class DbDriver { 36 37 static { 38 String dataBaseVendor = null; 39 try { 40 ResourceBundle dbconf = ResourceBundle 41 .getBundle("org/jresearch/gossip/resources/db"); 42 dataBaseVendor = dbconf.getString("dataBaseVendor"); 43 Class clazz = DbDriverRegistry.getInstance().getDriverClass( 44 dataBaseVendor); 45 if (null == clazz) 46 throw new RuntimeException ("Database driver [" + dataBaseVendor 47 + "] not supported."); 48 DbDriver.instance = (DbDriver) clazz.newInstance(); 49 } catch (InstantiationException e) { 50 e.printStackTrace(System.err); 51 throw new RuntimeException ("Database driver [" + dataBaseVendor 52 + "] can not be initialized."); 53 } catch (IllegalAccessException e) { 54 e.printStackTrace(System.err); 55 throw new RuntimeException ("Database driver [" + dataBaseVendor 56 + "] can not be initialized."); 57 } 58 } 59 60 private static DbDriver instance; 61 62 public static DbDriver getInstance() { 63 return instance; 64 } 65 66 protected Queries queries; 67 68 71 public Queries getQueries() { 72 return this.queries; 73 } 74 75 85 public abstract Object mapObjectType(Object object) 86 throws ClassCastException ; 87 88 97 public abstract int getLastRowIdx(int startIdx, int length); 98 99 } 100 | Popular Tags |