Repository navigation
Use prepared statement for all record for Oracle Reverse Replication #4628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
bce3ea4
a507b9b
9dc8b94
edc4b81
16b0c0a
975b53b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,12 +58,7 @@ public void write( | |
| statement = pstmt; | ||
| int paramIdx = 1; | ||
| for (Object param : params) { | ||
| if (param instanceof byte[]) { | ||
| byte[] bytes = (byte[]) param; | ||
| pstmt.setBlob(paramIdx++, new java.io.ByteArrayInputStream(bytes), bytes.length); | ||
| } else { | ||
| pstmt.setObject(paramIdx++, param); | ||
| } | ||
| bindParameter(pstmt, paramIdx++, param); | ||
| } | ||
| pstmt.executeUpdate(); | ||
| } else { | ||
|
|
@@ -86,4 +81,15 @@ public void write( | |
| } | ||
| } | ||
| } | ||
|
|
||
| /** Binds a prepared statement parameter. Sources can override this for type specific binding. */ | ||
| protected void bindParameter(java.sql.PreparedStatement pstmt, int paramIdx, Object param) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there any value in the refactor on this method ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed in [https://github.com//pull/4628#discussion_r4717510296], we might need specific bind handling to few types, respactive JDBCDAO per source will need this method for doing it. Like for oracle this method will be overriden for bounding different types in this loop: setFixedCHAR for CHAR/NCHAR, setNString/setNClob for national types, streamed setClob for large CLOBs, and typed setNull. This might require for other source as well if when we do prepared statement, hence I abstracted out this method. |
||
| throws java.sql.SQLException { | ||
| if (param instanceof byte[]) { | ||
| byte[] bytes = (byte[]) param; | ||
| pstmt.setBlob(paramIdx, new java.io.ByteArrayInputStream(bytes), bytes.length); | ||
| } else { | ||
| pstmt.setObject(paramIdx, param); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure why this variation in flow is required. Do we need the rawValues flag here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CustomTransformation is shared across different source's IT (Mysql/PG/Oracle). In Oracle we are using prepared statement which will bind the value as it is from CustomTransformation, while other source's are using inline values, so they need sql literals for it.
Hence we have added this flag for passing rawValues for oracle and sql literals for other. Once other sources are also starts using prepared statement, we can remove this rawValues flag.