1 2 28 29 30 34 35 package xeus.bottomline; 36 37 import java.sql.Connection ; 38 import java.sql.Driver ; 39 import java.sql.DriverManager ; 40 import java.sql.DriverPropertyInfo ; 41 import java.sql.SQLException ; 42 import java.util.Properties ; 43 44 import org.apache.log4j.Logger; 45 46 import xeus.bottomline.util.JdbcUrl; 47 48 52 public class BottomlineDriver implements Driver { 53 54 private static final int MAJOR_VERSION = 1; 55 private static final int MINOR_VERSION = 0; 56 public static final String USER_PREFIX = "jdbc:bottomline:"; 57 static Logger logger=Logger.getLogger(BottomlineDriver.class); 58 59 static { 60 try { 61 DriverManager.registerDriver(new BottomlineDriver()); 62 } catch (SQLException e) { 63 e.printStackTrace(); 64 } 65 } 66 67 70 public Connection connect(String url, Properties props) throws SQLException { 71 logger.debug(">>>>>>>>>>> In connect"); 72 73 if (!url.startsWith(USER_PREFIX)) 74 return null; 75 76 BottomlineConnection conn; 77 try { 78 JdbcUrl jurl=JdbcUrl.parse(url); 79 80 url=jurl.getUrl(); 81 props.putAll(jurl.getQueryMap()); 82 83 conn = new BottomlineConnection(url, props); 84 } catch (Exception e) { 85 SQLException sqle= new SQLException (e.getMessage()); 86 sqle.setStackTrace(e.getStackTrace()); 87 88 throw sqle; 89 } 90 91 return conn; 92 } 93 94 97 public boolean acceptsURL(String url) throws SQLException { 98 logger.debug(">>>>>>>>>>>> In accept"); 99 return url.startsWith(USER_PREFIX); 100 } 101 102 105 public DriverPropertyInfo [] getPropertyInfo(String url, Properties info) 106 throws SQLException { 107 logger.debug(">>>>>>>>>>> In prop Info"); 108 109 DriverPropertyInfo pinfo[] = new DriverPropertyInfo [2]; 110 DriverPropertyInfo p; 111 112 p = new DriverPropertyInfo (BottomlineConstants.USER, null); 113 p.value = info.getProperty(BottomlineConstants.USER); 114 p.required = true; 115 pinfo[0] = p; 116 p = new DriverPropertyInfo (BottomlineConstants.PASSWORD, null); 117 p.value = info.getProperty(BottomlineConstants.PASSWORD); 118 p.required = true; 119 pinfo[1] = p; 120 121 return pinfo; 122 } 123 124 127 public int getMajorVersion() { 128 return MAJOR_VERSION; 129 } 130 131 134 public int getMinorVersion() { 135 return MINOR_VERSION; 136 } 137 138 141 public boolean jdbcCompliant() { 142 logger.debug(">>>>>>>>>>> In compliance"); 143 return true; 144 } 145 } 146 | Popular Tags |