pranavbhandari24 commented on code in PR #25824:
URL: https://github.com/apache/beam/pull/25824#discussion_r1173126873
##########
sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java:
##########
@@ -630,6 +652,11 @@ && getConnectionInitSqls().get() != null
if (getDriverClassLoader() != null) {
basicDataSource.setDriverClassLoader(getDriverClassLoader());
}
+ if (getDriverJars() != null) {
+ URLClassLoader classLoader =
Review Comment:
No, passing in a jar here should be enough. Users will not need to have the
jar in the classpath or add the jar in `filesToStage`.
`driverJars` parameter should be used in the case where the driver jar is
not available in the classpath. Jars passed in using this parameter will be
localized and passed in using `basicDataSource.setDriverClassLoader()`, which
will then be used to load the JDBC driver. [1]
This change will be helpful for templates, since we want the template to run
with any database, and adding all possible database drivers is infeasible. We
have done this in google-provided templates by creating a copy of JdbcIO called
DynamicJdbcIO [2].
[1]
https://commons.apache.org/proper/commons-dbcp/apidocs/org/apache/commons/dbcp2/BasicDataSource.html#setDriverClassLoader-java.lang.ClassLoader-
[2]
https://github.com/GoogleCloudPlatform/DataflowTemplates/blob/main/v1/src/main/java/com/google/cloud/teleport/io/DynamicJdbcIO.java
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]