Package io.odysz.semantic.DA
Class Connects
java.lang.Object
io.odysz.semantic.DA.Connects
Connection configurations and DB table meta data manager.
- Author:
- odys-z@github.com
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
close()
static int[]
static int[]
Commit to default connection.static int[]
static int[]
static int[]
connIds()
static String
static io.odysz.common.dbtype
driverType
(String conn) static boolean
static io.odysz.semantics.meta.TableMeta
static String
getSmtcsPath
(String conn) Get the smtcs file path configured in connects.xml.static void
parse connects.xml, setup connections configured in table "drvmnger", for JDBC DriverManger, and "dbcp", for JDBC connection-pooled connection managed by container.static boolean
Build database tables' meta.protected static XMLTable
loadMetaCfgs
(String connId) static String
static String
compose paged sql, e.g.static io.odysz.common.dbtype
parseDrvType
(String type) Convert names like "sqlit" todbtype
.static AnResultset
static AnResultset
static void
static void
Set table meta (providing a chance of extending table's semantics and keep a single copy for DB's meta).static String
Mapping client function id to data connection according to configuration.
-
Field Details
-
metas
-
-
Constructor Details
-
Connects
public Connects()
-
-
Method Details
-
parseDrvType
Convert names like "sqlit" todbtype
.- Parameters:
type
-- Returns:
- db type
- Throws:
SemanticException
-
getAllConnIds
-
defltConn
-
init
parse connects.xml, setup connections configured in table "drvmnger", for JDBC DriverManger, and "dbcp", for JDBC connection-pooled connection managed by container.- Parameters:
xmlDir
- configure file folder
-
close
public static void close() -
select
- Throws:
SQLException
-
select
- Throws:
SQLException
-
pagingSql
public static String pagingSql(String conn, String sql, int page, int size) throws io.odysz.transact.x.TransException compose paged sql, e.g. for Oracle:
select * from (sql) t where rownum > 0 and row num < 14- Parameters:
sql
-page
-size
-- Returns:
- sql
- Throws:
io.odysz.transact.x.TransException
-
pagingSql
public static String pagingSql(io.odysz.common.dbtype dt, String sql, int pageIx, int pgSize) throws io.odysz.transact.x.TransException - Throws:
io.odysz.transact.x.TransException
-
commit
public static int[] commit(io.odysz.semantics.IUser usr, ArrayList<String> sqls, int... flags) throws SQLException, io.odysz.transact.x.TransException Commit to default connection.- Parameters:
usr
-sqls
-flags
-- Returns:
- affected row count
- Throws:
SQLException
io.odysz.transact.x.TransException
-
commit
public static int[] commit(io.odysz.semantics.IUser usr, ArrayList<String> sqls, ArrayList<Clob> lobs, int... flags) throws SQLException - Throws:
SQLException
-
commit
public static int[] commit(String conn, io.odysz.semantics.IUser usr, String sql, int... flags) throws SQLException, io.odysz.transact.x.TransException - Throws:
SQLException
io.odysz.transact.x.TransException
-
commit
public static int[] commit(String conn, io.odysz.semantics.IUser usr, ArrayList<String> sqls, int... flags) throws SQLException, io.odysz.transact.x.TransException - Throws:
SQLException
io.odysz.transact.x.TransException
-
commit
public static int[] commit(io.odysz.semantics.IUser usr, String sql) throws SQLException, io.odysz.transact.x.TransException - Throws:
SQLException
io.odysz.transact.x.TransException
-
driverType
-
connIds
-
loadMeta
public static HashMap<String,io.odysz.semantics.meta.TableMeta> loadMeta(String conn) throws SemanticException, SQLException Build database tables' meta.
- Parameters:
conn
-- Returns:
- metas
- Throws:
IOException
SQLException
Exception
SemanticException
-
loadMetaCfgs
protected static XMLTable loadMetaCfgs(String connId) throws SAXException, IOException, SemanticException - Throws:
SAXException
IOException
SemanticException
-
getMeta
public static HashMap<String,io.odysz.semantics.meta.TableMeta> getMeta(String connId) throws SemanticException, SQLException - Throws:
SemanticException
SQLException
-
getMeta
public static io.odysz.semantics.meta.TableMeta getMeta(String connId, String tbl) throws SemanticException, SQLException - Parameters:
connId
-tbl
-- Returns:
- table meta
- Throws:
SemanticException
SQLException
IOException
- Since:
- 1.4.25
-
setMeta
public static void setMeta(String connId, io.odysz.semantics.meta.TableMeta m) throws SemanticException, SQLException Set table meta (providing a chance of extending table's semantics and keep a single copy for DB's meta).- Parameters:
connId
-m
-- Throws:
SemanticException
SQLException
IOException
SAXException
- Since:
- 1.4.25
-
getSmtcsPath
Get the smtcs file path configured in connects.xml.- Parameters:
conn
-- Returns:
- smtcs (e.g. semantics.xml)
-
getDebug
-
setDebug
-
uri2conn
Mapping client function id to data connection according to configuration. Uri pattern is matched with prefix of strings' in db config.xml.- Parameters:
uri
-- Returns:
- Throws:
SemanticException
- uri is null
-
isqlite
-