public static ConnectionImpl buildConnection(TeiidDriver driver, String vdbName, String version, Properties props) throws SQLException { StringBuilder sb = new StringBuilder(); sb.append("jdbc:teiid:").append(vdbName); //$NON-NLS-1$ if (version != null) { sb.append(".").append(version); //$NON-NLS-1$ } sb.append(";"); //$NON-NLS-1$ if (props.getProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION) == null) { props.setProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION, "true"); //$NON-NLS-1$ } if (props.getProperty(LocalProfile.TRANSPORT_NAME) == null) { props.setProperty(LocalProfile.TRANSPORT_NAME, "odata"); } if (props.getProperty(LocalProfile.WAIT_FOR_LOAD) == null) { props.setProperty(LocalProfile.WAIT_FOR_LOAD, "0"); //$NON-NLS-1$ } ConnectionImpl connection = driver.connect(sb.toString(), props); return connection; }
public String getDatabaseProductVersion() throws SQLException { return TeiidDriver.getInstance().getMajorVersion() + "." + TeiidDriver.getInstance().getMinorVersion(); //$NON-NLS-1$ }
private Connection getConnection(String vdbName, String version, boolean passthough) throws SQLException { TeiidDriver driver = new TeiidDriver(); return driver.connect("jdbc:teiid:"+vdbName+"."+version+";"+(passthough?"PassthroughAuthentication=true;":""), null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } }
/** * <p>Get the name of this JDBC driver * @return String representing the driver's name * @throws SQLException, if the connection is already closed. */ public String getDriverName() throws SQLException { return TeiidDriver.getInstance().getDriverName(); }
/** * <p>Gets this drivers minor version number * @return int representing the driver's minor version */ public int getDriverMinorVersion() { return TeiidDriver.getInstance().getMinorVersion(); }
@Help.Doc(text = "Get a Teiid connection") public static TeiidSql connect( @Help.Doc(text = "url") String url, @Help.Doc(text = "user") String user, @Help.Doc(text = "password") String password) throws SQLException { Properties info = new Properties(); if (user != null) { info.setProperty(TeiidURL.CONNECTION.USER_NAME, user); } if (password != null) { info.setProperty(TeiidURL.CONNECTION.PASSWORD, password); } Connection c = TeiidDriver.getInstance().connect(url, info); if (c == null) { throw new SQLException("Invalid url " + url); } return new TeiidSql(c); }
public void parseUrl(Properties props) throws SQLException { super.parseURL(iurl, props); } }
/** * <p>Gets this drivers major version number * @return int representing the driver's major version */ public int getDriverMajorVersion() { return TeiidDriver.getInstance().getMajorVersion(); }
/** Invalid format of urls*/ @Test public void testAcceptsURL2() throws Exception { assertTrue(!TeiidDriver.getInstance().acceptsURL("jdbc:matamatrix:test")); //$NON-NLS-1$ assertTrue(!TeiidDriver.getInstance().acceptsURL("metamatrix:test")); //$NON-NLS-1$ assertTrue(!TeiidDriver.getInstance().acceptsURL("jdbc&matamatrix:test")); //$NON-NLS-1$ assertTrue(!TeiidDriver.getInstance().acceptsURL("jdbc;metamatrix:test")); //$NON-NLS-1$ }
@Override public Connection open() throws SQLException, TeiidProcessingException { this.connection = buildConnection(TeiidDriver.getInstance(), this.vdbName, this.vdbVersion, this.properties); ODBCServerRemoteImpl.setConnectionProperties(connection); ODBCServerRemoteImpl.setConnectionProperties(connection, this.properties); getVDBInternal(); return this.connection; }
public TeiidDataSource() { this.driver = new TeiidDriver(); }
/** Invalid format of urls*/ @Test public void testAcceptsURL2() throws Exception { assertTrue(!drv.acceptsURL("jdbc:matamatrix:test")); //$NON-NLS-1$ assertTrue(!drv.acceptsURL("metamatrix:test")); //$NON-NLS-1$ assertTrue(!drv.acceptsURL("jdbc&matamatrix:test")); //$NON-NLS-1$ assertTrue(!drv.acceptsURL("jdbc;metamatrix:test")); //$NON-NLS-1$ }
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { if(info == null) { info = new Properties(); } else { info = PropertiesUtils.clone(info); } // construct list of driverPropertyInfo objects List<DriverPropertyInfo> driverProps = new LinkedList<DriverPropertyInfo>(); parseURL(url, info); for (String property: JDBCURL.KNOWN_PROPERTIES.keySet()) { DriverPropertyInfo dpi = new DriverPropertyInfo(property, info.getProperty(property)); if (property.equals(BaseDataSource.VDB_NAME)) { dpi.required = true; } dpi.description = JDBCPlugin.Util.getString(property + "_desc"); //$NON-NLS-1$ if (JDBCPlugin.Util.keyExists(property + "_choices")) { //$NON-NLS-1$ dpi.choices = JDBCPlugin.Util.getString(property + "_choices").split(","); //$NON-NLS-1$ //$NON-NLS-2$ } driverProps.add(dpi); } // create an array of DriverPropertyInfo objects DriverPropertyInfo [] propInfo = new DriverPropertyInfo[driverProps.size()]; // copy the elements from the list to the array return driverProps.toArray(propInfo); }
/** * <p>Get the name of this JDBC driver * @return String representing the driver's name * @throws SQLException, if the connection is already closed. */ public String getDriverName() throws SQLException { return TeiidDriver.getInstance().getDriverName(); }
/** * <p>Gets this drivers minor version number * @return int representing the driver's minor version */ public int getDriverMinorVersion() { return TeiidDriver.getInstance().getMinorVersion(); }
/** * <p>Gets this drivers major version number * @return int representing the driver's major version */ public int getDriverMajorVersion() { return TeiidDriver.getInstance().getMajorVersion(); }
public TeiidDataSource() { this.driver = new TeiidDriver(); }
@Test public void testAccepts() throws Exception { assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:12345")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:vdb")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:12345")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:vdb")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:8294601c-9fe9-4244-9499-4a012c5e1476_vdb")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:8294601c-9fe9-4244-9499-4a012c5e1476_vdb@mm://localhost:12345")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:test_vdb@mm://local-host:12345")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:test_vdb@mm://local_host:12345")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:test_vdb.1@mm://local_host:12345")); //$NON-NLS-1$ assertTrue(drv.acceptsURL("jdbc:teiid:test_vdb.10@mm://local_host:12345")); //$NON-NLS-1$ }
public void testGetConnectionWithUser() throws SQLException { TeiidDriver td = Mockito.mock(TeiidDriver.class); TeiidDataSource tds = new TeiidDataSource(td); tds.setDatabaseName("y"); tds.setUser("%25user"); tds.setServerName("x"); tds.getConnection("user", "password"); ArgumentCaptor<Properties> argument = ArgumentCaptor.forClass(Properties.class); Mockito.verify(td).connect(Mockito.eq("jdbc:teiid:y@mm://x:0"), argument.capture()); Properties p = argument.getValue(); assertEquals("user", p.getProperty(BaseDataSource.USER_NAME)); }
private Connection getConnection(String vdbName, String version, boolean passthough) throws SQLException { TeiidDriver driver = new TeiidDriver(); return driver.connect("jdbc:teiid:"+vdbName+"."+version+";"+(passthough?"PassthroughAuthentication=true;":""), null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } }