From 1a1a494ea61c01bf25ba0ab3cee3a5ae7fa4c6b4 Mon Sep 17 00:00:00 2001 From: Nigel Westbury Date: Thu, 26 Nov 2015 12:34:10 +0000 Subject: [PATCH] IGNITE1993 remove non-standard SQL clause so table for JDBC discovery works in Oracle --- .../tcp/ipfinder/jdbc/TcpDiscoveryJdbcIpFinder.java | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/jdbc/TcpDiscoveryJdbcIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/jdbc/TcpDiscoveryJdbcIpFinder.java index 69fa3f8..23b1dc7 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/jdbc/TcpDiscoveryJdbcIpFinder.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/jdbc/TcpDiscoveryJdbcIpFinder.java @@ -58,6 +58,9 @@ import static java.sql.Connection.TRANSACTION_READ_COMMITTED; * The database will contain 1 table which will hold IP addresses. */ public class TcpDiscoveryJdbcIpFinder extends TcpDiscoveryIpFinderAdapter { + /** Name of the address table. */ + public static final String ADDRS_TABLE_NAME = "tbl_addrs"; + /** Query to get addresses. */ public static final String GET_ADDRS_QRY = "select hostname, port from tbl_addrs"; @@ -301,12 +304,18 @@ public class TcpDiscoveryJdbcIpFinder extends TcpDiscoveryIpFinderAdapter { conn.setTransactionIsolation(TRANSACTION_READ_COMMITTED); - // Create tbl_addrs. - stmt = conn.createStatement(); - - stmt.executeUpdate(CREATE_ADDRS_TABLE_QRY); - - conn.commit(); + DatabaseMetaData dbm = conn.getMetaData(); + + // check if the table of node addresses is there + ResultSet tables = dbm.getTables(null, null, ADDRS_TABLE_NAME, null); + if (!tables.next()) + { + // Table does not exist + // Create tbl_addrs. + stmt = conn.createStatement(); + stmt.executeUpdate(CREATE_ADDRS_TABLE_QRY); + conn.commit(); + } committed = true; -- 1.8.4.msysgit.0