private String getConnStringForDriver( Driver _drv, String _host, String _port, String _db, String _user, String _pw) { if (_drv instanceof AlphanumericDBDriver) { logger.error("Returned null conn str (OK) for: " + _drv.getClass().getName()); return null; } else { if (_drv instanceof IVectorialDatabaseDriver) { IVectorialDatabaseDriver geo_driver = (IVectorialDatabaseDriver) _drv; return geo_driver.getConnectionString(_host, _port, _db, _user, _pw); } else { logger.error("Unexpected driver type: " + _drv.getClass().getName()); return null; } } }
public static IConnection getConnectionForDriver( Driver _drv, String conn_str, String _host, String _port, String _db, String _user, String _pw) throws Exception { IConnection resp = null; int intport = 0; if (_drv instanceof AlphanumericDBDriver) { try { intport = Integer.parseInt(_port); } catch (Exception ex) { throw new DBException(ex); } AlphanumericDBDriver alpha_drv = (AlphanumericDBDriver) _drv; Connection _c_ = alpha_drv.getConnection(_host, intport, _db, _user, _pw); ConnectionJDBC resp2 = new ConnectionJDBC(); resp2.setDataConnection(_c_, _user, _pw); resp = resp2; } else { if (_drv instanceof IVectorialDatabaseDriver) { IVectorialDatabaseDriver geo_driver = (IVectorialDatabaseDriver) _drv; resp = ConnectionFactory.createConnection(conn_str, _user, _pw); } else { logger.error("Did not create IConnection, Unexpected driver: " + _drv.getClass().getName()); } } return resp; }