Skip to content

Commit e13cd6a

Browse files
authored
Merge pull request #216 from jster1357/develop
add logic for TNS Descriptor
2 parents ebdd010 + 4578f28 commit e13cd6a

16 files changed

Lines changed: 89 additions & 36 deletions

oracle-plugin/docs/Oracle-action.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ Properties
2222

2323
**Port:** Port that Oracle is running on.
2424

25-
**SID/Service Name:** Oracle connection point (Database name or Service name).
25+
**Connection Type** Whether to use an SID, Service Name, or TNS Connect Descriptor when connecting to the database.
2626

27-
**Connection Type** Whether to use an SID or Service Name when connecting to the database.
27+
**SID/Service Name/TNS Connect Descriptor:** Oracle connection point (Database name, Service name, or a TNS Connect Descriptor). When using TNS, place
28+
the full TNS Connect Descriptor in the text field. For example:
29+
(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 123.123.123.123)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)
30+
(SERVICE_NAME = XE)))
2831

2932
**Username:** User identity for connecting to the specified database.
3033

oracle-plugin/docs/Oracle-batchsink.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ You also can use the macro function ${conn(connection-name)}.
2828

2929
**Port:** Port that Oracle is running on.
3030

31-
**SID/Service Name:** Oracle connection point (Database name or Service name).
32-
3331
**Role** Login role of the user when connecting to the database. For eg, NORMAL, SYSDBA, SYSOPER, etc.
3432

3533
**Connection Type** Whether to use an SID or Service Name when connecting to the database.
3634

35+
**SID/Service Name/TNS Connect Descriptor:** Oracle connection point (Database name, Service name, or a TNS Connect Descriptor). When using TNS, place
36+
the full TNS Connect Descriptor in the text field. For example:
37+
(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 123.123.123.123)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)
38+
(SERVICE_NAME = XE)))
39+
3740
**Table Name:** Name of the table to export to.
3841

3942
**Username:** User identity for connecting to the specified database.

oracle-plugin/docs/Oracle-batchsource.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ You also can use the macro function ${conn(connection-name)}.
2929

3030
**Port:** Port that Oracle is running on.
3131

32-
**SID/Service Name:** Oracle connection point (Database name or Service name).
32+
**Connection Type** Whether to use an SID, Service Name, or TNS Connect Descriptor when connecting to the database.
3333

34-
**Role** Login role of the user when connecting to the database.
34+
**SID/Service Name/TNS Connect Descriptor:** Oracle connection point (Database name, Service name, or a TNS Connect Descriptor). When using TNS, place
35+
the full TNS Connect Descriptor in the text field. For example:
36+
(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 123.123.123.123)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)
37+
(SERVICE_NAME = XE)))
3538

36-
**Connection Type** Whether to use an SID or Service Name when connecting to the database.
39+
**Role** Login role of the user when connecting to the database.
3740

3841
**Import Query:** The SELECT query to use to import data from the specified table.
3942
You can specify an arbitrary number of columns to import, or import all columns using \*. The Query should

oracle-plugin/docs/Oracle-connector.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ authentication. Optional for databases that do not require authentication.
2222

2323
**Password:** Password to use to connect to the specified database.
2424

25-
**Connection Type:** Whether to use an SID or Service Name when connecting to the database.
25+
**Connection Type** Whether to use an SID, Service Name, or TNS Connect Descriptor when connecting to the database.
2626

27-
**SID/Service Name:** Oracle connection point (Database name or Service name).
27+
**SID/Service Name/TNS Connect Descriptor:** Oracle connection point (Database name, Service name, or a TNS Connect Descriptor). When using TNS, place
28+
the full TNS Connect Descriptor in the text field. For example:
29+
(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 123.123.123.123)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)
30+
(SERVICE_NAME = XE)))
2831

2932
**Role:** Login role of the user when connecting to the database.
3033

oracle-plugin/docs/Oracle-postaction.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ If set to 'failure', the action will only be executed if the pipeline run failed
3030

3131
**Port:** Port that Oracle is running on.
3232

33-
**SID/Service Name:** Oracle connection point (Database name or Service name).
33+
**Connection Type** Whether to use an SID, Service Name, or TNS Connect Descriptor when connecting to the database.
3434

35-
**Connection Type** Whether to use an SID or Service Name when connecting to the database.
35+
**SID/Service Name/TNS Connect Descriptor:** Oracle connection point (Database name, Service name, or a TNS Connect Descriptor). When using TNS, place
36+
the full TNS Connect Descriptor in the text field. For example:
37+
(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 123.123.123.123)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)
38+
(SERVICE_NAME = XE)))
3639

3740
**Username:** User identity for connecting to the specified database.
3841

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleAction.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ public static class OracleActionConfig extends DBSpecificQueryConfig {
5757

5858
@Override
5959
public String getConnectionString() {
60-
if (OracleConstants.SERVICE_CONNECTION_TYPE.equals(this.connectionType)) {
61-
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT,
62-
host, port, database);
60+
if (OracleConstants.TNS_CONNECTION_TYPE.equals(this.connectionType)) {
61+
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_TNS_FORMAT, database);
62+
} else if (OracleConstants.SERVICE_CONNECTION_TYPE.equals(this.connectionType)) {
63+
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT, host, port, database);
64+
} else {
65+
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SID_FORMAT, host, port, database);
6366
}
64-
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SID_FORMAT, host, port, database);
6567
}
6668

6769

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnector.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,15 @@ protected String getConnectionString(@Nullable String database) {
110110
if (database == null) {
111111
return config.getConnectionString();
112112
}
113-
if (OracleConstants.SERVICE_CONNECTION_TYPE.equals(config)) {
113+
if (OracleConstants.TNS_CONNECTION_TYPE.equals(config.getConnectionType())) {
114+
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_TNS_FORMAT, database);
115+
} else if (OracleConstants.SERVICE_CONNECTION_TYPE.equals(config.getConnectionType())) {
114116
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT, config.getHost(),
115-
config.getPort(), database);
117+
config.getPort(), database);
118+
} else {
119+
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SID_FORMAT,
120+
config.getHost(), config.getPort(), database);
116121
}
117-
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SID_FORMAT,
118-
config.getHost(), config.getPort(), database);
119122
}
120123

121124
@Override

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnectorConfig.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,13 @@ public OracleConnectorConfig(String host, int port, String user, String password
5656

5757
@Override
5858
public String getConnectionString() {
59-
if (OracleConstants.SERVICE_CONNECTION_TYPE.equals(connectionType)) {
59+
if (OracleConstants.TNS_CONNECTION_TYPE.equals(getConnectionType())) {
60+
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_TNS_FORMAT, database);
61+
} else if (OracleConstants.SERVICE_CONNECTION_TYPE.equals(getConnectionType())) {
6062
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT, host, getPort(), database);
63+
} else {
64+
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SID_FORMAT, host, getPort(), database);
6165
}
62-
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SID_FORMAT, host, getPort(), database);
6366
}
6467

6568
@Name(OracleConstants.CONNECTION_TYPE)

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ private OracleConstants() {
2727
public static final String PLUGIN_NAME = "Oracle";
2828
public static final String ORACLE_CONNECTION_STRING_SID_FORMAT = "jdbc:oracle:thin:@%s:%s:%s";
2929
public static final String ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT = "jdbc:oracle:thin:@//%s:%s/%s";
30+
public static final String ORACLE_CONNECTION_STRING_TNS_FORMAT = "jdbc:oracle:thin:@%s";
3031
public static final String DEFAULT_BATCH_VALUE = "defaultBatchValue";
3132
public static final String DEFAULT_ROW_PREFETCH = "defaultRowPrefetch";
3233
public static final String SERVICE_CONNECTION_TYPE = "service";
3334
public static final String CONNECTION_TYPE = "connectionType";
3435
public static final String ROLE = "role";
3536
public static final String NAME_DATABASE = "database";
37+
public static final String TNS_CONNECTION_TYPE = "TNS";
3638
}

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OraclePostAction.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ public static class OracleQueryActionConfig extends DBSpecificQueryActionConfig
5757

5858
@Override
5959
public String getConnectionString() {
60-
if (OracleConstants.SERVICE_CONNECTION_TYPE.equals(this.connectionType)) {
61-
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT,
62-
host, port, database);
60+
if (OracleConstants.TNS_CONNECTION_TYPE.equals(this.connectionType)) {
61+
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_TNS_FORMAT, database);
62+
} else if (OracleConstants.SERVICE_CONNECTION_TYPE.equals(this.connectionType)) {
63+
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT, host, port, database);
64+
} else {
65+
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SID_FORMAT, host, port, database);
6366
}
64-
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SID_FORMAT, host, port, database);
6567
}
6668

6769
@Override

0 commit comments

Comments
 (0)