use of org.wso2.carbon.apimgt.api.APIMgtDAOException in project carbon-apimgt by wso2.
the class DAOFactory method getTagDAO.
public static TagDAO getTagDAO() throws APIMgtDAOException {
TagDAO tagDAO = null;
try (Connection connection = DAOUtil.getConnection()) {
String driverName = connection.getMetaData().getDriverName();
if (driverName.contains(MYSQL) || driverName.contains(H2)) {
tagDAO = new TagDAOImpl();
} else if (driverName.contains(DB2)) {
} else if (driverName.contains(MS_SQL) || driverName.contains(MICROSOFT)) {
tagDAO = new TagDAOImpl();
} else if (driverName.contains(POSTGRE)) {
tagDAO = new TagDAOImpl();
} else if (driverName.contains(ORACLE)) {
tagDAO = new TagDAOImpl();
} else {
throw new APIMgtDAOException("Unhandled DB driver: " + driverName + " detected", ExceptionCodes.APIM_DAO_EXCEPTION);
}
} catch (SQLException e) {
throw new APIMgtDAOException(DAOUtil.DAO_ERROR_PREFIX + "getting TagDAO", e);
}
setup();
return tagDAO;
}
use of org.wso2.carbon.apimgt.api.APIMgtDAOException in project carbon-apimgt by wso2.
the class DAOFactory method getFunctionDAO.
/**
* To get the FunctionDAO object. Depends on different vendors.
*
* @return FunctionDAO object
* @throws APIMgtDAOException In case of unhandled DB type or SQLException
*/
public static FunctionDAO getFunctionDAO() throws APIMgtDAOException {
FunctionDAO functionDAO = null;
try (Connection connection = DAOUtil.getConnection()) {
String driverName = connection.getMetaData().getDriverName();
if (driverName.contains(MYSQL) || driverName.contains(H2)) {
functionDAO = new FunctionDAOImpl();
} else if (driverName.contains(DB2)) {
} else if (driverName.contains(MS_SQL) || driverName.contains(MICROSOFT)) {
functionDAO = new FunctionDAOImpl();
} else if (driverName.contains(POSTGRE)) {
functionDAO = new FunctionDAOImpl();
} else if (driverName.contains(ORACLE)) {
functionDAO = new FunctionDAOImpl();
} else {
throw new APIMgtDAOException("Unhandled DB driver: " + driverName + " detected", ExceptionCodes.APIM_DAO_EXCEPTION);
}
} catch (SQLException e) {
throw new APIMgtDAOException(DAOUtil.DAO_ERROR_PREFIX + "getting FunctionDAO", e);
}
setup();
return functionDAO;
}
use of org.wso2.carbon.apimgt.api.APIMgtDAOException in project carbon-apimgt by wso2.
the class DAOFactory method getAnalyticsDaoImplForVendor.
private static AnalyticsDAO getAnalyticsDaoImplForVendor(Connection connection) throws SQLException, APIMgtDAOException {
AnalyticsDAO analyticsDAO = null;
String driverName = connection.getMetaData().getDriverName();
if (driverName.contains(MYSQL) || driverName.contains(H2)) {
analyticsDAO = new AnalyticsDAOImpl();
} else if (driverName.contains(DB2)) {
} else if (driverName.contains(MS_SQL) || driverName.contains(MICROSOFT)) {
analyticsDAO = new AnalyticsDAOImpl();
} else if (driverName.contains(POSTGRE)) {
analyticsDAO = new AnalyticsDAOImpl();
} else if (driverName.contains(ORACLE)) {
analyticsDAO = new AnalyticsDAOImpl();
} else {
throw new APIMgtDAOException("Unhandled DB Type detected");
}
return analyticsDAO;
}
use of org.wso2.carbon.apimgt.api.APIMgtDAOException in project carbon-apimgt by wso2.
the class DAOFactory method getApiDAO.
public static ApiDAO getApiDAO() throws APIMgtDAOException {
ApiDAO apiDAO = null;
if (System.getProperty(EDITOR_MODE) != null) {
String filePath;
if ((filePath = System.getProperty(EDITOR_SAVE_PATH)) != null) {
apiDAO = new ApiFileDAOImpl(filePath);
return apiDAO;
} else {
throw new APIMgtDAOException("Editor archive storage path not provided", ExceptionCodes.APIM_DAO_EXCEPTION);
}
}
try (Connection connection = DAOUtil.getConnection()) {
String driverName = connection.getMetaData().getDriverName();
if (driverName.contains(MYSQL)) {
apiDAO = new ApiDAOImpl(new MysqlSQLStatements());
} else if (driverName.contains(H2)) {
apiDAO = new ApiDAOImpl(new H2SQLStatements());
} else if (driverName.contains(DB2)) {
} else if (driverName.contains(MS_SQL) || driverName.contains(MICROSOFT)) {
apiDAO = new ApiDAOImpl(new MssqlSQLStatements());
} else if (driverName.contains(POSTGRE)) {
apiDAO = new ApiDAOImpl(new PostgresSQLStatements());
} else if (driverName.contains(ORACLE)) {
apiDAO = new ApiDAOImpl(new OracleSQLStatements());
} else {
throw new APIMgtDAOException("Unhandled DB driver: " + driverName + " detected", ExceptionCodes.APIM_DAO_EXCEPTION);
}
} catch (SQLException e) {
throw new APIMgtDAOException(DAOUtil.DAO_ERROR_PREFIX + "getting ApiDAO", e);
}
setup();
return apiDAO;
}
use of org.wso2.carbon.apimgt.api.APIMgtDAOException in project carbon-apimgt by wso2.
the class DAOFactory method getPolicyDAO.
public static PolicyDAO getPolicyDAO() throws APIMgtDAOException {
PolicyDAO policyDAO = null;
try (Connection connection = DAOUtil.getConnection()) {
String driverName = connection.getMetaData().getDriverName();
if (driverName.contains(MYSQL) || driverName.contains(H2)) {
policyDAO = new PolicyDAOImpl();
} else if (driverName.contains(DB2)) {
} else if (driverName.contains(MS_SQL) || driverName.contains(MICROSOFT)) {
policyDAO = new PolicyDAOImpl();
} else if (driverName.contains(POSTGRE)) {
policyDAO = new PolicyDAOImpl();
} else if (driverName.contains(ORACLE)) {
policyDAO = new PolicyDAOImpl();
} else {
throw new APIMgtDAOException("Unhandled DB driver: " + driverName + " detected", ExceptionCodes.APIM_DAO_EXCEPTION);
}
} catch (SQLException e) {
throw new APIMgtDAOException(DAOUtil.DAO_ERROR_PREFIX + "getting PolicyDAO", e);
}
setup();
return policyDAO;
}
Aggregations