cancel
Showing results for 
Search instead for 
Did you mean: 

Obtain Database Name from Data Source?

falko_menge
Champ in-the-making
Champ in-the-making
Would it be possible to retrieve the database name from the data source, e.g., the JDBC URL? This way, the data source is the only configuration, which needs to be changed for switching to another DB, i.e., for continuous integration tests.
2 REPLIES 2

falko_menge
Champ in-the-making
Champ in-the-making
Just to clarify things: We don't mean to change the database configuration at runtime.

We stumbled over this, when we studied the Spring examples. There one needs to pass a data source and a data base name to the org.activiti.spring.ProcessEngineFactoryBean, which passes it on to the ProcessEngineConfiguration. The DbSqlSessionFactory does:

    this.statementMappings = databaseSpecificStatements.get(processEngineConfiguration.getDatabaseName());
followed by:

    DataSource dataSource = processEngineConfiguration.getDataSource();
    if (dataSource==null) {

      String jdbcDriver = processEngineConfiguration.getJdbcDriver();
      String jdbcUrl = processEngineConfiguration.getJdbcUrl();
      …

Deriving the string for identifying database specific statements from the JDBC URL would save users the additional configuration property. It somehow violates the concept of a data source if additional database settings are needed.

Ok, I just saw that the interface javax.sql.DataSource doesn't seem to have methods for retrieving the JDBC URL. This explains the need for an additional property.

tombaeyens
Champ in-the-making
Champ in-the-making
Was writing: "How would you derive the JDBC URL when the user configures a data source (either through spring or in an app server environment)?  then we don't know what type of datasource.  so we can't cast to get to the jdbc details."

and then saw that you figured the same yourself 🙂