GeeCON Prague 2014*
The moose likes JDBC and the fly likes How to specify a schema for a DataSource? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to specify a schema for a DataSource?" Watch "How to specify a schema for a DataSource?" New topic
Author

How to specify a schema for a DataSource?

James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
I have a Spring application which sets up a DataSource bean using standard properties such as URL, username, password, etc. I want to specify that this DataSource bean use a specific schema, but I can't find any information on how I can specify which schema I will be using through this DataSource. For example I have the production schema duplicated as a development schema, and I want to use the development schema for my development so I don't step on ay production data. How can I configure my DataSource so that the correct (development) schema is used for JDBC operations when I do my development and testing?

Thanks for any suggestions!


--James
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2501
    
    8

Originally posted by James Adams:
I want to specify that this DataSource bean use a specific schema, but I can't find any information on how I can specify which schema I will be using through this DataSource. For example I have the production schema duplicated as a development schema, and I want to use the development schema for my development so I don't step on ay production data. How can I configure my DataSource so that the correct (development) schema is used for JDBC operations when I do my development and testing?


Depends on the database you use, but in general:

You can create a test database account that points to your test schema,
and a production database account that points to your production schema.

Switching schemas can be done by selecting a different user in your DataSource setup.

What database are you using?

Regards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
So the schema used is tied to the account specified by the username and password properties. Thanks!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to specify a schema for a DataSource?