use of org.apache.ignite.IgniteJdbcThinDataSource in project ignite by apache.
the class JdbcThinDataSourceSelfTest method testJndi.
/**
* @throws Exception If failed.
*/
@Test
public void testJndi() throws Exception {
IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource();
ids.setUrl("jdbc:ignite:thin://127.0.0.1");
InitialContext ic = getInitialContext();
ic.bind("ds/test", ids);
IgniteJdbcThinDataSource ds = (IgniteJdbcThinDataSource) ic.lookup("ds/test");
assertTrue("Cannot looking up DataSource from JNDI", ds != null);
assertEquals(ids.getUrl(), ds.getUrl());
}
use of org.apache.ignite.IgniteJdbcThinDataSource in project ignite by apache.
the class JdbcThinDataSourceSelfTest method testSqlHints.
/**
* @throws Exception If failed.
*/
@Test
public void testSqlHints() throws Exception {
IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource();
ids.setUrl("jdbc:ignite:thin://127.0.0.1");
try (Connection conn = ids.getConnection()) {
for (JdbcThinTcpIo io : ios(conn)) {
assertFalse(io.connectionProperties().isAutoCloseServerCursor());
assertFalse(io.connectionProperties().isCollocated());
assertFalse(io.connectionProperties().isEnforceJoinOrder());
assertFalse(io.connectionProperties().isLazy());
assertFalse(io.connectionProperties().isDistributedJoins());
assertFalse(io.connectionProperties().isReplicatedOnly());
}
}
ids.setAutoCloseServerCursor(true);
ids.setCollocated(true);
ids.setEnforceJoinOrder(true);
ids.setLazy(true);
ids.setDistributedJoins(true);
ids.setReplicatedOnly(true);
try (Connection conn = ids.getConnection()) {
for (JdbcThinTcpIo io : ios(conn)) {
assertTrue(io.connectionProperties().isAutoCloseServerCursor());
assertTrue(io.connectionProperties().isCollocated());
assertTrue(io.connectionProperties().isEnforceJoinOrder());
assertTrue(io.connectionProperties().isLazy());
assertTrue(io.connectionProperties().isDistributedJoins());
assertTrue(io.connectionProperties().isReplicatedOnly());
}
}
}
use of org.apache.ignite.IgniteJdbcThinDataSource in project ignite by apache.
the class JdbcThinDataSourceSelfTest method testSocketBuffers.
/**
* @throws Exception If failed.
*/
@Test
public void testSocketBuffers() throws Exception {
final IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource();
ids.setUrl("jdbc:ignite:thin://127.0.0.1");
ids.setSocketReceiveBuffer(111);
ids.setSocketSendBuffer(111);
try (Connection conn = ids.getConnection()) {
for (JdbcThinTcpIo io : ios(conn)) {
assertEquals(111, io.connectionProperties().getSocketReceiveBuffer());
assertEquals(111, io.connectionProperties().getSocketSendBuffer());
}
}
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
ids.setSocketReceiveBuffer(-1);
ids.getConnection();
return null;
}
}, SQLException.class, "Property cannot be lower than 0 [name=socketReceiveBuffer, value=-1]");
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
ids.setSocketReceiveBuffer(1024);
ids.setSocketSendBuffer(-1);
ids.getConnection();
return null;
}
}, SQLException.class, "Property cannot be lower than 0 [name=socketSendBuffer, value=-1]");
}
use of org.apache.ignite.IgniteJdbcThinDataSource in project ignite by apache.
the class JDBCThinDriver method connectionFromDatasource.
public Connection connectionFromDatasource() throws SQLException {
// tag::connection-from-data-source[]
// Or open connection via DataSource.
IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource();
ids.setUrl("jdbc:ignite:thin://127.0.0.1");
ids.setDistributedJoins(true);
Connection conn = ids.getConnection();
return conn;
}
use of org.apache.ignite.IgniteJdbcThinDataSource in project ignite by apache.
the class JdbcThinDataSourceSelfTest method testTcpNoDelay.
/**
* @throws Exception If failed.
*/
@Test
public void testTcpNoDelay() throws Exception {
IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource();
ids.setUrl("jdbc:ignite:thin://127.0.0.1");
try (Connection conn = ids.getConnection()) {
for (JdbcThinTcpIo io : ios(conn)) assertTrue(io.connectionProperties().isTcpNoDelay());
}
ids.setTcpNoDelay(false);
try (Connection conn = ids.getConnection()) {
for (JdbcThinTcpIo io : ios(conn)) assertFalse(io.connectionProperties().isTcpNoDelay());
}
}
Aggregations