Package com.majorana.maj_orm.ORM
Class MajoranaDBConnectionFactory
java.lang.Object
com.majorana.maj_orm.ORM.MajoranaDBConnectionFactory
This class represents a factory to create database connections using any of the credentials
in the DBEnvSetup class of database from the environment
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Get a row mapper ot get a localdate time from a database -
Constructor Summary
ConstructorDescriptionMajoranaDBConnectionFactory
(DBEnvSetup dbs, CassandraState cassandraState) Constructor, make a connection factory from the DB Environment, and with cassandra option -
Method Summary
Modifier and TypeMethodDescriptionOptional<org.springframework.data.cassandra.core.CassandraTemplate>
Get a cassandra template for the named database sourceOptional<com.datastax.oss.driver.api.core.CqlSession>
getCqlSession
(MajDataSourceName dbName) Get a CqlSession (cassandra) for the named datab sourcegetDBTime
(MajDataSourceName dbName) Get the database time zone given the database nameOptional<org.springframework.jdbc.core.JdbcTemplate>
getJdbcTemplate
(MajDataSourceName dbSrcName) Get the a jdnc template for the named database sourceOptional<org.springframework.data.cassandra.core.CassandraTemplate>
Get the main cassandra templateOptional<org.springframework.jdbc.core.JdbcTemplate>
Get trhe main jdbc templateOptional<org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate>
Get a named parameter template for the main templateGet the variant of the main databasegetMysqlConn
(MajDataSourceName dbSrcName) Get an SQL Connection for the named datasourceOptional<org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate>
Get a named parameter jdnc template for the named datasourcegetSchemaInDB
(MajDataSourceName dbSrcName) Get the group schema from the MajDatasourceNamegetVariant
(MajDataSourceName dbName) Get the variant of the named datasourcetranslate
(String sql, DatabaseVariant dbVariant) Translate SQL according to the database variant
-
Constructor Details
-
MajoranaDBConnectionFactory
Constructor, make a connection factory from the DB Environment, and with cassandra option- Parameters:
dbs
- - DBEnvSetup env var for the credentialscassandraState
- - is cassandra to to be used
-
-
Method Details
-
getMainDBName
- Returns:
- get the name of the main database
-
getMainVariant
Get the variant of the main database- Returns:
-
getSchemaInDB
Get the group schema from the MajDatasourceName- Parameters:
dbSrcName
-- Returns:
- group from credentials from the source
-
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
Get an SQL Connection for the named datasource- Parameters:
dbSrcName
-- Returns:
- SQL Connection
- Throws:
SQLException
-
getVariant
Get the variant of the named datasource- Parameters:
dbName
-- Returns:
-
translate
Translate SQL according to the database variant- Parameters:
sql
- indbVariant
-- Returns:
- sql out
-
getDBTime
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:
-