diff --git a/oracle-plugin/pom.xml b/oracle-plugin/pom.xml
index b21152fcd..0b93edc88 100644
--- a/oracle-plugin/pom.xml
+++ b/oracle-plugin/pom.xml
@@ -28,6 +28,16 @@
4.0.0
+
+ com.oracle.database.xml
+ xdb
+ 23.5.0.24.07
+
+
+ com.oracle.database.xml
+ xmlparserv2
+ 23.5.0.24.07
+
io.cdap.cdap
cdap-etl-api
@@ -118,7 +128,8 @@
io.cdap.plugin.db.sink.*;
org.apache.commons.lang;
org.apache.commons.logging.*;
- org.codehaus.jackson.*
+ org.codehaus.jackson.*;
+ oracle.*;
*;inline=false;scope=compile
true
diff --git a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceDBRecord.java b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceDBRecord.java
index 3f7c2a20a..0e333a00c 100644
--- a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceDBRecord.java
+++ b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceDBRecord.java
@@ -169,6 +169,16 @@ protected void writeNonNullToDB(PreparedStatement stmt, Schema fieldSchema,
}
}
+
+
+ private String getXmlDataAsString(ResultSet resultSet, int columnIndex) throws SQLException {
+ // Retrieve the XML data as a String
+ String xmlString = resultSet.getString(columnIndex);
+
+ //Check if the XML content is not null and return it
+ return xmlString != null ? xmlString : "No XML data present."; // Testing purpose
+ }
+
/**
* Creates an instance of 'oracle.sql.TIMESTAMPTZ' which corresponds to the specified timestamp with time zone string.
* @param connection sql connection.
@@ -341,6 +351,10 @@ private void handleOracleSpecificType(ResultSet resultSet, StructuredRecord.Buil
case OracleSourceSchemaReader.LONG_RAW:
recordBuilder.set(field.getName(), resultSet.getBytes(columnIndex));
break;
+ case OracleSourceSchemaReader.XML_TYPE:
+ String xmlData = getXmlDataAsString(resultSet, columnIndex);
+ recordBuilder.set(field.getName(), xmlData);
+ break;
case Types.DECIMAL:
case Types.NUMERIC:
// This is the only way to differentiate FLOAT/REAL columns from other numeric columns, that based on NUMBER.
diff --git a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceSchemaReader.java b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceSchemaReader.java
index 7d35f9bc7..aea89e153 100644
--- a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceSchemaReader.java
+++ b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceSchemaReader.java
@@ -43,6 +43,7 @@ public class OracleSourceSchemaReader extends CommonSchemaReader {
public static final int BFILE = -13;
public static final int LONG = -1;
public static final int LONG_RAW = -4;
+ public static final int XML_TYPE = 2009; // Add XMLType constant
/**
* Logger instance for Oracle Schema reader.
@@ -61,7 +62,7 @@ public class OracleSourceSchemaReader extends CommonSchemaReader {
LONG,
LONG_RAW,
Types.NUMERIC,
- Types.DECIMAL
+ Types.DECIMAL, XML_TYPE
);
private final String sessionID;
@@ -95,6 +96,9 @@ public Schema getSchema(ResultSetMetaData metadata, int index) throws SQLExcepti
case INTERVAL_DS:
case INTERVAL_YM:
case LONG:
+ case XML_TYPE:
+ LOG.info(String.format("Column '%s' is of XMLType, converting to STRING for CDAP.",
+ metadata.getColumnName(index)));
return Schema.of(Schema.Type.STRING);
case Types.NUMERIC:
case Types.DECIMAL: