Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • Multiple DBs Publich to JNDI

    I have multiple DBs that I'm accessing from the same application. I have them both defined in my server.properties file and they work with the ds.xml just fine. However, I would like to be able to access both data sources from my server. I'm getting the default database from JNDI just fine using:

    Code:
    sql.defaultDatabase.jndi.publish.path:isomorphic/jdbc/defaultDatabase
    Is there a way to publish the second database to JNDI as well?

  • #2
    Use the DataSouce.dbName property to have a particular DataSource use a SQL database that is not the default.

    Comment


    • #3
      Yeah I got that to work. I'm talking about utilizing the JDBC data source in other server side code. I'm retrieving the default datasource as a Spring bean like this:

      Code:
          @Bean
          public DataSource dataSource() throws NamingException {
              return (DataSource) new JndiTemplate().lookup((String) com.isomorphic.base.Config.getProperty("sql.defaultDatabase.jndi.publish.path"));
          }
      I'm not sure how I can get the other datasource from JNDI. Here's my server.properties:

      Code:
      sql.defaultDatabase.jndi.publish.path:isomorphic/jdbc/defaultDatabase
      sql.defaultDatabase:Mysql
      sql.Mysql.type:mysql
      sql.Mysql.interface.type:dataSource
      sql.Mysql.driver:org.mariadb.jdbc.MariaDbDataSource
      sql.Mysql.driver.serverName:${db.host}
      sql.Mysql.driver.portNumber:3306
      sql.Mysql.driver.databaseName:${db.name}
      sql.Mysql.driver.user:${db.user}
      sql.Mysql.driver.password:${db.password}
      sql.PBDB.type:mysql
      sql.PBDB.interface.type:dataSource
      sql.PBDB.driver:org.mariadb.jdbc.MariaDbDataSource
      sql.PBDB.driver.serverName:${pbdb.db.host}
      sql.PBDB.driver.portNumber:3306
      sql.PBDB.driver.databaseName:${pbdb.db.name}
      sql.PBDB.driver.user:${pbdb.db.user}
      sql.PBDB.driver.password:${pbdb.db.password}
      sql.PBDB.jndi.publish.path:isomorphic/jdbc/PBDB
      I added the property "sql.PBDB.jndi.publish.path", but that doesn't seem to work. Is this possible?

      Comment

      Working...
      X