-
Notifications
You must be signed in to change notification settings - Fork 171
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
SNOW-1899165: Add a method to create a data source (SnowflakeConnectionPoolDataSource and SnowflakeBasicDataSource) from a map of properties #2049
Comments
hi - thanks for raising it. calling individual methods is possible, but should not be required. You should be able to populate the connection string with 2 other methods too:
Can you please take a look at https://docs.snowflake.com/en/developer-guide/jdbc/jdbc-configure#connection-parameters under |
Hello, thanks for your answer !
The only method I can see is protected Properties getProperties() {
return this.properties;
} Am I missing something ?
I did not think of putting everything in connection String, I can try that :) |
by Properties props = new Properties();
props.put("parameter1", parameter1Value);
props.put("parameter2", parameter2Value);
Connection con = DriverManager.getConnection("jdbc:snowflake://<account_identifier>.snowflakecomputing.com/", props); as seen in the documentation referenced in my comment; could this work too? edit: I see now JDBC driver also supports the almost-universal whch, depending on your use-case, might also work for you and if you're using multiple Snowflake drivers (Python, etc) then its even reusable across different drivers. |
I want to avoid using DataSource dataSource = new SnowflakeBasicDataSource();
dataSource.setUrl();
dataSource.setUser("myuser");
dataSource.setPassword("mypass");
...
Connection connection = dataSource.getConnection() |
got you. then this is surely an enhancement request, and the team will take a look, without any timeline attached. (To set some kind of expectations, due to other critical priorities, it is almost sure this won't be addressed in the next upcoming quarter, so if you're inclined to actually implement it too, that would be more than appreciated) |
What is the current behavior?
Currently, when creating a SnowflakeBasicDataSource, we need to call individual methods to set each parameter, such as
setPasscode
.In my current application I have the properties I want to use as a
Map<String, String>
orMap<SFSessionProperty, String>
, so in order to set all the properties into the Data Source I have to run a huge switch to call the correct method depending on the property.This is not only tiring but also there are complex cases which are not straightforward:
setPrivateKeyFile
map to several properties (SFSessionProperty.PRIVATE_KEY_FILE
,SFSessionProperty.PRIVATE_KEY_PWD
andSFSessionProperty.AUTHENTICATOR
) so it's not a simple 1:1 matchingWhat is the desired behavior?
Add a new method to create a data source from a
Map<SFSessionProperty, String>
, or at least expose a methodsetProperty(SFSessionProperty, String)
of the DataSource.How would this improve
snowflake-jdbc
?This would make the use of the DataSource API easier.
The text was updated successfully, but these errors were encountered: