1 23 24 package org.dbforms.conprovider; 25 26 import java.sql.Connection ; 27 import java.sql.SQLException ; 28 29 30 31 39 public abstract class ConnectionProvider { 40 41 private ConnectionProviderPrefs prefs = null; 42 43 48 public ConnectionProvider() throws Exception { 49 } 50 51 56 public void setPrefs(ConnectionProviderPrefs prefs) { 57 this.prefs = prefs; 58 } 59 60 61 66 public ConnectionProviderPrefs getPrefs() { 67 return prefs; 68 } 69 70 71 78 protected abstract Connection getConnection() throws SQLException ; 79 80 81 86 protected abstract void init() throws Exception ; 87 88 89 98 protected Connection getConnection(int isolationLevel) 99 throws SQLException { 100 Connection con = getConnection(); 101 con.setTransactionIsolation(isolationLevel); 102 con.setAutoCommit(false); 103 104 return con; 105 } 106 107 108 116 protected String getLastToken(String str, 117 String tokenSeparator) { 118 str = str.trim(); 119 120 return str.substring(str.lastIndexOf(tokenSeparator) + 1, str.length()); 121 } 122 } 123 | Popular Tags |