Search in sources :

Example 6 with IgniteJdbcThinDataSource

use of org.apache.ignite.IgniteJdbcThinDataSource in project ignite by apache.

the class JdbcThinDataSourceSelfTest method testUrlCompose.

/**
 * @throws Exception If failed.
 */
@Test
public void testUrlCompose() throws Exception {
    IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource();
    ids.setAddresses("127.0.0.1:" + ClientConnectorConfiguration.DFLT_PORT);
    assertEquals("jdbc:ignite:thin://127.0.0.1:10800/PUBLIC", ids.getUrl());
    ids.setSchema("test");
    assertEquals("jdbc:ignite:thin://127.0.0.1:10800/test", ids.getUrl());
    assertEquals("jdbc:ignite:thin://127.0.0.1:10800/test", ids.getURL());
    ids.setAddresses("127.0.0.1:" + ClientConnectorConfiguration.DFLT_PORT + ".." + (ClientConnectorConfiguration.DFLT_PORT + 10), "myhost:10801..10802");
    ids.setSchema("test2");
    assertEquals("jdbc:ignite:thin://127.0.0.1:10800..10810,myhost:10801..10802/test2", ids.getURL());
}
Also used : IgniteJdbcThinDataSource(org.apache.ignite.IgniteJdbcThinDataSource) Test(org.junit.Test)

Example 7 with IgniteJdbcThinDataSource

use of org.apache.ignite.IgniteJdbcThinDataSource in project ignite by apache.

the class JdbcThinDataSourceSelfTest method testResetUrl.

/**
 * @throws Exception If failed.
 */
@Test
public void testResetUrl() throws Exception {
    IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource();
    ids.setUrl("jdbc:ignite:thin://127.0.0.1:10800/test?lazy=true");
    assertEquals("test", ids.getSchema());
    assertTrue(ids.isLazy());
    ids.setUrl("jdbc:ignite:thin://mydomain.org,localhost?collocated=true");
    assertNull(ids.getSchema());
    assertFalse(ids.isLazy());
    assertTrue(ids.isCollocated());
}
Also used : IgniteJdbcThinDataSource(org.apache.ignite.IgniteJdbcThinDataSource) Test(org.junit.Test)

Aggregations

IgniteJdbcThinDataSource (org.apache.ignite.IgniteJdbcThinDataSource)7 Test (org.junit.Test)6 Connection (java.sql.Connection)4 JdbcThinConnection (org.apache.ignite.internal.jdbc.thin.JdbcThinConnection)3 JdbcThinTcpIo (org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo)3 SQLException (java.sql.SQLException)1 InitialContext (javax.naming.InitialContext)1 NamingException (javax.naming.NamingException)1