use of net.heartsome.cat.common.bean.MetaData in project translationstudio8 by heartsome.
the class OperateSystemDBImpl method createSysDb.
/**
* 创建系统库
* @return
* @throws SQLException
*/
public int createSysDb() throws SQLException {
MetaData data = null;
try {
data = (MetaData) metaData.clone();
data.setDatabaseName(Constants.HSSYSDB);
} catch (CloneNotSupportedException e) {
logger.warn("", e);
return Constants.FAILURE;
}
List<String> createTables = dbConfig.getCreateSysTables();
return createDB(createTables, data);
}
use of net.heartsome.cat.common.bean.MetaData in project translationstudio8 by heartsome.
the class SystemDBOperator method createSysDb.
/**
* 创建系统库
* @return
* @throws SQLException
*/
public int createSysDb() throws SQLException {
MetaData data = null;
try {
data = (MetaData) metaData.clone();
data.setDatabaseName(Constants.HSSYSDB);
} catch (CloneNotSupportedException e) {
logger.warn("", e);
return Constants.FAILURE;
}
String createDb = Utils.replaceParams(dbConfig.getCreateSysDb(), data);
List<String> createTables = dbConfig.getCreateSysTables();
return createDB(createDb, createTables, data);
}
use of net.heartsome.cat.common.bean.MetaData in project translationstudio8 by heartsome.
the class SystemDBOperator method addSysDb.
/**
* 插入系统库
* @param dbName
* 数据库名称
* @param quality
* 是否优化
*/
public void addSysDb(String dbName, String quality, int type) {
MetaData data = null;
try {
data = (MetaData) metaData.clone();
data.setDatabaseName(Constants.HSSYSDB);
} catch (CloneNotSupportedException e) {
logger.warn("", e);
return;
}
String driver = dbConfig.getDriver();
String url = Utils.replaceParams(dbConfig.getDbURL(), data);
Properties prop = Utils.replaceParams(dbConfig.getConfigProperty(), data);
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = getConnection(driver, url, prop);
String insertDb = Utils.replaceParams(dbConfig.getInsertSysDb(), data);
stmt = conn.prepareStatement(insertDb);
stmt.setString(1, dbName);
stmt.setString(2, quality);
stmt.setInt(3, type);
stmt.execute();
} catch (ClassNotFoundException e) {
logger.warn("", e);
} catch (SQLException e) {
logger.warn("", e);
} finally {
freeConnection(stmt, conn);
}
}
use of net.heartsome.cat.common.bean.MetaData in project translationstudio8 by heartsome.
the class SystemDBOperator method checkSysDb.
/**
* 检查系统库是否已经创建
* @return true 已创建, false 没有创建
*/
public boolean checkSysDb() {
MetaData data = null;
try {
data = (MetaData) metaData.clone();
data.setDatabaseName(Constants.HSSYSDB);
} catch (CloneNotSupportedException e) {
logger.warn("", e);
return false;
}
Connection conn = null;
Statement stmt = null;
String driver = dbConfig.getDriver();
String url = Utils.replaceParams(dbConfig.getDbURL(), data);
Properties prop = Utils.replaceParams(dbConfig.getConfigProperty(), data);
try {
conn = getConnection(driver, url, prop);
} catch (ClassNotFoundException e) {
logger.warn(Messages.getString("database.SystemDBOperator.logger3"), e);
return false;
} catch (SQLException e) {
logger.warn("", e);
return false;
} finally {
freeConnection(stmt, conn);
}
return true;
}
use of net.heartsome.cat.common.bean.MetaData in project translationstudio8 by heartsome.
the class SystemDBOperator method checkDbExistOnServer.
/**
* 检查数据库在当前服务器上是否已经存在,而非在R8系统中已经存在<br>
* @return true已经存在.false不存在
*/
public boolean checkDbExistOnServer() {
Connection conn = null;
MetaData data = null;
try {
data = (MetaData) metaData.clone();
} catch (CloneNotSupportedException e) {
logger.warn("", e);
return false;
}
try {
String url = Utils.replaceParams(dbConfig.getDbURL(), data);
String driver = dbConfig.getDriver();
Properties prop = Utils.replaceParams(dbConfig.getConfigProperty(), data);
conn = getConnection(driver, url, prop);
} catch (ClassNotFoundException e) {
logger.error(Messages.getString("database.SystemDBOperator.logger1"), e);
return false;
} catch (SQLException e) {
// Just check ,so don't need record the exception
return false;
} finally {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
logger.warn("", e);
}
}
}
return true;
}
Aggregations