lidavidm commented on code in PR #607:
URL: https://github.com/apache/arrow-adbc/pull/607#discussion_r1177199523
##########
java/driver/jdbc/src/main/java/org/apache/arrow/adbc/driver/jdbc/JdbcDriver.java:
##########
@@ -47,20 +50,64 @@ public JdbcDriver(BufferAllocator allocator) {
@Override
public AdbcDatabase open(Map<String, Object> parameters) throws
AdbcException {
- Object target = parameters.get(PARAM_URL);
- if (!(target instanceof String)) {
- throw AdbcException.invalidArgument("[JDBC] Must provide String " +
PARAM_URL + " parameter");
+ DataSource dataSource = getParam(DataSource.class, parameters,
PARAM_DATASOURCE);
+ // XXX(apache/arrow-adbc#316): allow "url" to align with C/Go
+ String target = getParam(String.class, parameters, "url", PARAM_URL);
+ if (dataSource != null && target != null) {
+ throw AdbcException.invalidArgument(
+ "[JDBC] Can only provide one of " + PARAM_URL + " and " +
PARAM_DATASOURCE);
}
- Object quirks = parameters.get(PARAM_SQL_QUIRKS);
- if (quirks != null) {
- Preconditions.checkArgument(
- quirks instanceof SqlQuirks,
- String.format(
- "[JDBC] %s must be a SqlQuirks instance, not %s",
- PARAM_SQL_QUIRKS, quirks.getClass().getName()));
- } else {
+
+ SqlQuirks quirks = getParam(SqlQuirks.class, parameters, PARAM_SQL_QUIRKS);
+ if (quirks == null) {
quirks = new SqlQuirks();
}
- return new JdbcDatabase(allocator, (String) target, (SqlQuirks) quirks);
+
+ String username = getParam(String.class, parameters, "username");
+ String password = getParam(String.class, parameters, "password");
+ if ((username != null && password == null) || (username == null &&
password != null)) {
+ throw AdbcException.invalidArgument(
+ "[JDBC] Must provide both or neither of username and password");
+ }
+
+ if (target != null) {
+ dataSource = new UrlDataSource(target);
+ }
Review Comment:
I thought I had checked that PARAM_DATASOURCE was not provided in this case,
I'll fix that
--
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]