Class MajoranaDBConnectionFactory

java.lang.Object
com.majorana.maj_orm.ORM.MajoranaDBConnectionFactory

public class MajoranaDBConnectionFactory extends Object
This class represents a factory to create database connections using any of the credentials in the DBEnvSetup class of database from the environment
  • Constructor Details

    • MajoranaDBConnectionFactory

      public MajoranaDBConnectionFactory(DBEnvSetup dbs, CassandraState cassandraState)
      Constructor, make a connection factory from the DB Environment, and with cassandra option
      Parameters:
      dbs - - DBEnvSetup env var for the credentials
      cassandraState - - is cassandra to to be used
  • Method Details

    • getMainDBName

      public MajDataSourceName getMainDBName()
      Returns:
      get the name of the main database
    • getMainVariant

      public DatabaseVariant getMainVariant()
      Get the variant of the main database
      Returns:
    • getSchemaInDB

      public String getSchemaInDB(MajDataSourceName dbSrcName)
      Get the group schema from the MajDatasourceName
      Parameters:
      dbSrcName -
      Returns:
      group from credentials from the source
    • getMainJdbcTemplate

      public Optional<org.springframework.jdbc.core.JdbcTemplate> getMainJdbcTemplate()
      Get trhe main jdbc template
      Returns:
      an JbdcTemplate
    • getMainNamedParamJdbcTemplate

      public Optional<org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate> getMainNamedParamJdbcTemplate()
      Get a named parameter template for the main template
      Returns:
      named parameter jdbc template
    • getMainCassandraTemplate

      public Optional<org.springframework.data.cassandra.core.CassandraTemplate> getMainCassandraTemplate()
      Get the main cassandra template
      Returns:
      cassandra template
    • getJdbcTemplate

      public Optional<org.springframework.jdbc.core.JdbcTemplate> getJdbcTemplate(MajDataSourceName dbSrcName)
      Get the a jdnc template for the named database source
      Parameters:
      dbSrcName -
      Returns:
    • getMysqlConn

      public Connection getMysqlConn(MajDataSourceName dbSrcName) throws SQLException
      Get an SQL Connection for the named datasource
      Parameters:
      dbSrcName -
      Returns:
      SQL Connection
      Throws:
      SQLException
    • getVariant

      public DatabaseVariant getVariant(MajDataSourceName dbName)
      Get the variant of the named datasource
      Parameters:
      dbName -
      Returns:
    • translate

      public String translate(String sql, DatabaseVariant dbVariant)
      Translate SQL according to the database variant
      Parameters:
      sql - in
      dbVariant -
      Returns:
      sql out
    • getDBTime

      public LocalDateTime getDBTime(MajDataSourceName dbName)
      Get the database time zone given the database name
      Parameters:
      dbName -
      Returns:
    • getCqlSession

      public Optional<com.datastax.oss.driver.api.core.CqlSession> getCqlSession(MajDataSourceName dbName)
      Get a CqlSession (cassandra) for the named datab source
      Parameters:
      dbName -
      Returns:
    • getCassandraTemplate

      public Optional<org.springframework.data.cassandra.core.CassandraTemplate> getCassandraTemplate(MajDataSourceName dbName)
      Get a cassandra template for the named database source
      Parameters:
      dbName -
      Returns:
    • getNamedParameterJdbcTemplate

      public Optional<org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate> getNamedParameterJdbcTemplate(MajDataSourceName dbName)
      Get a named parameter jdnc template for the named datasource
      Parameters:
      dbName -
      Returns: