Package edu.sc.seis.sod.hibernate
Class ConnMgr
java.lang.Object
edu.sc.seis.sod.hibernate.ConnMgr
public class ConnMgr
extends java.lang.Object
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DB_SERVER_PORT
static java.lang.String
DBPASSWORD_KEY
static java.lang.String
DBURL_KEY
static java.lang.String
DBUSER_KEY
static java.lang.String
DEFAULT
static java.lang.String
EDB
static java.lang.String
EDB_PROPS
static java.lang.String
HSQL
static java.lang.String
MCKOI
static java.lang.String
MYSQL
static java.lang.String
MYSQL_PROPS
static java.lang.String
ORACLE
static java.lang.String
ORACLE_PROPS
static java.lang.String
POSTGRES
static java.lang.String
POSTGRES_PROPS
-
Constructor Summary
Constructors Constructor Description ConnMgr()
-
Method Summary
Modifier and Type Method Description static void
addPropsLocation(java.lang.String loc)
Use this method to add loacations for sql property files to be stored When setDB is loaded, if there is a default.props file at that location, it will be added to the existing properties, and if one of the 'TYPE OF DB'.props exists, it will also be loaded.static boolean
checkDatabaseConn()
static java.sql.Connection
createConnection()
static java.lang.String
getDB_TYPE()
static java.util.Properties
getDBProps()
static java.lang.String
getDriver()
static java.lang.String
getPass()
static java.lang.String
getSQL(java.lang.String key)
static java.lang.String
getURL()
static java.lang.String
getUser()
static boolean
hasSQL(java.lang.String key)
static void
installDbProperties(java.util.Properties sysProperties, java.lang.String[] args)
static void
installDbProperties(java.util.Properties sysProperties, java.util.Properties dbProperties)
static void
main(java.lang.String[] args)
static java.util.Properties
readDbProperties(java.lang.String[] args)
static void
setDB()
Sets the ConnMgr to use the default db, which as of now is an in-memory HSQLDbstatic void
setDB(java.lang.String dbName)
Sets the DB to be used based on the default values for the name.static void
setDB(java.util.Properties newprops)
static void
setURL(java.lang.String url)
static void
setURL(java.lang.String url, java.lang.String databaseUser, java.lang.String databasePassword)
-
Field Details
-
DEFAULT
public static final java.lang.String DEFAULT- See Also:
- Constant Field Values
-
HSQL
public static final java.lang.String HSQL- See Also:
- Constant Field Values
-
MCKOI
public static final java.lang.String MCKOI- See Also:
- Constant Field Values
-
MYSQL
public static final java.lang.String MYSQL- See Also:
- Constant Field Values
-
MYSQL_PROPS
public static final java.lang.String MYSQL_PROPS- See Also:
- Constant Field Values
-
ORACLE
public static final java.lang.String ORACLE- See Also:
- Constant Field Values
-
ORACLE_PROPS
public static final java.lang.String ORACLE_PROPS- See Also:
- Constant Field Values
-
POSTGRES
public static final java.lang.String POSTGRES- See Also:
- Constant Field Values
-
POSTGRES_PROPS
public static final java.lang.String POSTGRES_PROPS- See Also:
- Constant Field Values
-
EDB
public static final java.lang.String EDB- See Also:
- Constant Field Values
-
EDB_PROPS
public static final java.lang.String EDB_PROPS- See Also:
- Constant Field Values
-
DB_SERVER_PORT
public static final java.lang.String DB_SERVER_PORT- See Also:
- Constant Field Values
-
DBURL_KEY
public static final java.lang.String DBURL_KEY- See Also:
- Constant Field Values
-
DBUSER_KEY
public static final java.lang.String DBUSER_KEY- See Also:
- Constant Field Values
-
DBPASSWORD_KEY
public static final java.lang.String DBPASSWORD_KEY- See Also:
- Constant Field Values
-
-
Constructor Details
-
ConnMgr
public ConnMgr()
-
-
Method Details
-
addPropsLocation
public static void addPropsLocation(java.lang.String loc)Use this method to add loacations for sql property files to be stored When setDB is loaded, if there is a default.props file at that location, it will be added to the existing properties, and if one of the 'TYPE OF DB'.props exists, it will also be loaded. -
setDB
public static void setDB() throws java.io.IOExceptionSets the ConnMgr to use the default db, which as of now is an in-memory HSQLDb- Throws:
java.io.IOException
-
setDB
public static void setDB(java.lang.String dbName) throws java.io.IOExceptionSets the DB to be used based on the default values for the name. Names fissuresUtil knows are ConnMgr.MCKOI, ConnMgr.HSQL, and ConnMgr.POSTGRES- Throws:
java.io.IOException
- if some of the props don't load
-
setDB
public static void setDB(java.util.Properties newprops) -
hasSQL
public static boolean hasSQL(java.lang.String key) -
getSQL
public static java.lang.String getSQL(java.lang.String key) -
getDriver
public static java.lang.String getDriver()- Returns:
- the classname of the jdbc driver.
-
getDB_TYPE
public static java.lang.String getDB_TYPE()- Returns:
- the database product, ie hsql, postgres, etc.
-
setURL
public static void setURL(java.lang.String url) -
setURL
public static void setURL(java.lang.String url, java.lang.String databaseUser, java.lang.String databasePassword) -
getURL
public static java.lang.String getURL() -
getPass
public static java.lang.String getPass() -
getUser
public static java.lang.String getUser() -
getDBProps
public static java.util.Properties getDBProps() -
createConnection
public static java.sql.Connection createConnection() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
installDbProperties
public static void installDbProperties(java.util.Properties sysProperties, java.util.Properties dbProperties) -
readDbProperties
public static java.util.Properties readDbProperties(java.lang.String[] args) -
installDbProperties
public static void installDbProperties(java.util.Properties sysProperties, java.lang.String[] args) -
checkDatabaseConn
public static boolean checkDatabaseConn() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
main
public static void main(java.lang.String[] args) throws java.sql.SQLException- Throws:
java.sql.SQLException
-