Search in sources :

Example 1 with MySQL

use of org.wso2.carbon.idp.mgt.util.IdPManagementConstants.MySQL in project carbon-apimgt by wso2.

the class DAOFactory method getAPISubscriptionDAO.

public static APISubscriptionDAO getAPISubscriptionDAO() throws APIMgtDAOException {
    APISubscriptionDAO apiSubscriptionDAO = null;
    try (Connection connection = DAOUtil.getConnection()) {
        String driverName = connection.getMetaData().getDriverName();
        if (driverName.contains(MYSQL) || driverName.contains(H2)) {
            apiSubscriptionDAO = new APISubscriptionDAOImpl();
        } else if (driverName.contains(DB2)) {
        } else if (driverName.contains(MS_SQL) || driverName.contains(MICROSOFT)) {
            apiSubscriptionDAO = new APISubscriptionDAOImpl();
        } else if (driverName.contains(POSTGRE)) {
            apiSubscriptionDAO = new APISubscriptionDAOImpl();
        } else if (driverName.contains(ORACLE)) {
            apiSubscriptionDAO = new APISubscriptionDAOImpl();
        } else {
            throw new APIMgtDAOException("Unhandled DB driver: " + driverName + " detected", ExceptionCodes.APIM_DAO_EXCEPTION);
        }
    } catch (SQLException e) {
        throw new APIMgtDAOException(DAOUtil.DAO_ERROR_PREFIX + "getting APISubscriptionDAO", e);
    }
    setup();
    return apiSubscriptionDAO;
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) APISubscriptionDAO(org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO) SQLException(java.sql.SQLException) Connection(java.sql.Connection)

Example 2 with MySQL

use of org.wso2.carbon.idp.mgt.util.IdPManagementConstants.MySQL 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;
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) TagDAO(org.wso2.carbon.apimgt.core.dao.TagDAO) SQLException(java.sql.SQLException) Connection(java.sql.Connection)

Example 3 with MySQL

use of org.wso2.carbon.idp.mgt.util.IdPManagementConstants.MySQL 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;
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) FunctionDAO(org.wso2.carbon.apimgt.core.dao.FunctionDAO)

Example 4 with MySQL

use of org.wso2.carbon.idp.mgt.util.IdPManagementConstants.MySQL 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;
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) AnalyticsDAO(org.wso2.carbon.apimgt.core.dao.AnalyticsDAO)

Example 5 with MySQL

use of org.wso2.carbon.idp.mgt.util.IdPManagementConstants.MySQL 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;
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ApiDAO(org.wso2.carbon.apimgt.core.dao.ApiDAO)

Aggregations

SQLException (java.sql.SQLException)21 Connection (java.sql.Connection)19 PreparedStatement (java.sql.PreparedStatement)10 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)10 ResultSet (java.sql.ResultSet)9 ArrayList (java.util.ArrayList)6 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)4 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)4 IdentityOAuth2Exception (org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception)4 Timestamp (java.sql.Timestamp)3 AccessTokenDO (org.wso2.carbon.identity.oauth2.model.AccessTokenDO)3 IOException (java.io.IOException)2 DatabaseMetaData (java.sql.DatabaseMetaData)2 NamedPreparedStatement (org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement)2 ApplicationBasicInfo (org.wso2.carbon.identity.application.common.model.ApplicationBasicInfo)2 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)2 NamedPreparedStatement (org.wso2.carbon.identity.oauth2.util.NamedPreparedStatement)2 WorkflowRequest (org.wso2.carbon.identity.workflow.mgt.dto.WorkflowRequest)2 InternalWorkflowException (org.wso2.carbon.identity.workflow.mgt.exception.InternalWorkflowException)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1