We are using the org.apache.commons.dbcp.BasicDataSource as parent class for our datasources in Spring.
Is it possible to specify which schema to use in either the "url" or in another property in the DBCP datasource?
You can get a list of the schemas using an SSMS or T-SQL query. To do this in SSMS, you would connect to the SQL instance, expand the SQL database and view the schemas under the security folder. Alternatively, you could use the sys. schemas to get a list of database schemas and their respective owners.
Connect to SQL Server Using JDBC Driver and Command Line datasource = "MSSQLServerAuth"; username = ""; password = ""; conn = database(datasource,username,password); Or, to connect without Windows authentication, use the configured JDBC data source and specify the user name username and the password pwd .
We can use JDBC URL to specify all kinds of parameters during connection setup. The usual parameters are database type, address, port, database name, etc. Since Postgres version 9.4. there is added support for specifying the current schema using URL.
jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]] where: jdbc:sqlserver:// (Required) is known as the subprotocol and is constant. serverName (Optional) is the address of the server to connect to.
I don't think it's possible to specify the schema since this is a function of the user, not the JDBC session. You should probably create a user with their default schema set to each schema you want to use, and then specify the user in the dbcp configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With