public String toString() { return getJDBCURL(); }
public String toString() { return getJDBCURL(); }
/** * @see java.lang.Object#toString() */ public String toString() { try { return buildURL().getJDBCURL(); } catch (TeiidSQLException e) { return e.getMessage(); } }
/** * @see java.lang.Object#toString() */ public String toString() { try { return buildURL().getJDBCURL(); } catch (TeiidSQLException e) { return e.getMessage(); } }
@Test public void testBuildEmbeedURL() { JDBCURL url = new JDBCURL("vdb", "/home/foo/deploy.properties", new Properties()); //$NON-NLS-1$ //$NON-NLS-2$ assertEquals("jdbc:teiid:vdb@/home/foo/deploy.properties", url.getJDBCURL()); //$NON-NLS-1$ Properties p = new Properties(); p.setProperty("user", "test"); //$NON-NLS-1$ //$NON-NLS-2$ p.setProperty("password", "pass"); //$NON-NLS-1$ //$NON-NLS-2$ p.setProperty("autoFailover", "true"); //$NON-NLS-1$ //$NON-NLS-2$ p.setProperty("any", "thing"); //$NON-NLS-1$ //$NON-NLS-2$ url = new JDBCURL("vdb", "/home/foo/deploy.properties", p); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue(url.getJDBCURL().startsWith("jdbc:teiid:vdb@/home/foo/deploy.properties;")); //$NON-NLS-1$ assertTrue(url.getJDBCURL().indexOf("any=thing")!=-1); //$NON-NLS-1$ assertTrue(url.getJDBCURL().indexOf("password=pass")!=-1); //$NON-NLS-1$ assertTrue(url.getJDBCURL().indexOf("autoFailover=true")!=-1); //$NON-NLS-1$ }
@Test public void testConstructor() { JDBCURL url = new JDBCURL("myVDB", "mm://myhost:12345",null); //$NON-NLS-1$ //$NON-NLS-2$ assertEquals("jdbc:teiid:myVDB@mm://myhost:12345", url.getJDBCURL()); //$NON-NLS-1$ Properties props = new Properties(); props.setProperty(BaseDataSource.USER_NAME, "myuser"); //$NON-NLS-1$ props.setProperty(BaseDataSource.PASSWORD, "mypassword"); //$NON-NLS-1$ props.put("ClieNTtOKeN", new Integer(1)); //$NON-NLS-1$ url = new JDBCURL("myVDB", "mm://myhost:12345", props); //$NON-NLS-1$ //$NON-NLS-2$ assertEquals("jdbc:teiid:myVDB@mm://myhost:12345;password=mypassword;user=myuser", url.getJDBCURL()); //$NON-NLS-1$ }
@Test public void testJDBCURLWithProperties() { String URL = "jdbc:teiid:bqt@mm://localhost:12345;version=1;user=%25xyz;password=***;logLevel=1;configFile=testdata/bqt/dqp_stmt_e2e.xmi;disableLocalTxn=true;autoFailover=false"; //$NON-NLS-1$ Properties expectedProperties = new Properties(); expectedProperties.setProperty("version", "1"); //$NON-NLS-1$ //$NON-NLS-2$ expectedProperties.setProperty("user", "%xyz"); //$NON-NLS-1$ //$NON-NLS-2$ expectedProperties.setProperty("password", "***"); //$NON-NLS-1$ //$NON-NLS-2$ expectedProperties.setProperty("logLevel", "1"); //$NON-NLS-1$ //$NON-NLS-2$ expectedProperties.setProperty("configFile", "testdata/bqt/dqp_stmt_e2e.xmi"); //$NON-NLS-1$ //$NON-NLS-2$ expectedProperties.setProperty(ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS, "true"); //$NON-NLS-1$ expectedProperties.setProperty(TeiidURL.CONNECTION.AUTO_FAILOVER, "false"); //$NON-NLS-1$ JDBCURL url = new JDBCURL(URL); assertEquals("bqt", url.getVDBName()); //$NON-NLS-1$ assertEquals("mm://localhost:12345", url.getConnectionURL()); //$NON-NLS-1$ assertEquals(expectedProperties, url.getProperties()); assertTrue(url.getJDBCURL().contains("user=%25xyz")); }
/** * Attempt to establish a database connection. * @param userName the database user on whose behalf the Connection is being made * @param password the user's password * @return a Connection to the database * @throws java.sql.SQLException if a database-access error occurs * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) */ public Connection getConnection(String userName, String password) throws java.sql.SQLException { // check if this is embedded connection if (getServerName() == null) { super.validateProperties(userName, password); final Properties props = buildEmbeddedProperties(userName, password); String url = new JDBCURL(getDatabaseName(), null, null).getJDBCURL(); return driver.connect(url, props); } // if not proceed with socket connection. validateProperties(userName,password); final Properties props = buildProperties(userName, password); return driver.connect(new JDBCURL(this.getDatabaseName(), buildServerURL(), null).getJDBCURL(), props); }
/** * Attempt to establish a database connection. * @param userName the database user on whose behalf the Connection is being made * @param password the user's password * @return a Connection to the database * @throws java.sql.SQLException if a database-access error occurs * @see javax.sql.DataSource#getConnection(java.lang.String, java.lang.String) */ public Connection getConnection(String userName, String password) throws java.sql.SQLException { // check if this is embedded connection if (getServerName() == null) { super.validateProperties(userName, password); final Properties props = buildEmbeddedProperties(userName, password); String url = new JDBCURL(getDatabaseName(), null, null).getJDBCURL(); return driver.connect(url, props); } // if not proceed with socket connection. validateProperties(userName,password); final Properties props = buildProperties(userName, password); return driver.connect(new JDBCURL(this.getDatabaseName(), buildServerURL(), null).getJDBCURL(), props); }
public void testBuildURLEncryptRequests() throws TeiidSQLException { final TeiidDataSource ds = new TeiidDataSource(); ds.setServerName("hostName"); //$NON-NLS-1$ ds.setDatabaseName("vdbName"); //$NON-NLS-1$ ds.setEncryptRequests(true); compareUrls("jdbc:teiid:vdbName@mm://hostname:0;fetchSize=2048;ApplicationName=JDBC;encryptRequests=true;VirtualDatabaseName=vdbName", ds.buildURL().getJDBCURL()); //$NON-NLS-1$ }
public void testBuildURL_AdditionalProperties() throws TeiidSQLException { final TeiidDataSource ds = new TeiidDataSource(); ds.setAdditionalProperties("foo=bar;a=b"); //$NON-NLS-1$ ds.setServerName("hostName"); //$NON-NLS-1$ ds.setDatabaseName("vdbName"); //$NON-NLS-1$ ds.setPortNumber(1); assertEquals("jdbc:teiid:vdbName@mm://hostname:1;ApplicationName=JDBC;VirtualDatabaseName=vdbName;a=b;fetchSize=2048;foo=bar", ds.buildURL().getJDBCURL()); //$NON-NLS-1$ }
public void testKerberos() throws SQLException { TeiidDataSource tds = new TeiidDataSource(); tds.setDatabaseName("y"); tds.setUser("%25user"); tds.setJaasName("x"); tds.setKerberosServicePrincipleName("z"); tds.setServerName("t"); compareUrls("jdbc:teiid:y@mm://t:0;fetchSize=2048;ApplicationName=JDBC;user=%2525user;jaasName=x;VirtualDatabaseName=y;kerberosServicePrincipleName=z", tds.buildURL().getJDBCURL()); }
public void helpTestBuildingURL2( final String vdbName, final String vdbVersion, final String serverName, final int portNumber, final String alternateServers, final String txnAutoWrap, final String partialMode, final int fetchSize, final boolean showPlan, final boolean secure, final boolean useJDBC4Semantics, final String expectedURL ) { final TeiidDataSource ds = new TeiidDataSource(); ds.setServerName(serverName); ds.setDatabaseVersion(vdbVersion); ds.setDatabaseName(vdbName); ds.setPortNumber(portNumber); ds.setFetchSize(fetchSize); ds.setAutoCommitTxn(txnAutoWrap); ds.setPartialResultsMode(partialMode); if(showPlan) { ds.setShowPlan(ShowPlan.ON.toString()); } ds.setSecure(secure); ds.setAlternateServers(alternateServers); ds.setUseJDBC4ColumnNameAndLabelSemantics(useJDBC4Semantics); String url; try { url = ds.buildURL().getJDBCURL(); } catch (TeiidSQLException e) { throw new RuntimeException(e); } compareUrls(expectedURL, url); }