Search in sources :

Example 1 with DB2XADataSource

use of com.ibm.db2.jcc.DB2XADataSource in project API by ca-cwds.

the class Db2XASample method buildDB2DataSource.

private static DB2XADataSource buildDB2DataSource(String user, String password, String serverName, int port, String databaseName) {
    DB2XADataSource ds = new DB2XADataSource();
    ds.setUser(user);
    ds.setPassword(password);
    ds.setServerName(serverName);
    ds.setPortNumber(port);
    ds.setDatabaseName(databaseName);
    ds.setDriverType(4);
    try {
        ds.getProperties().setProperty(DB2XADataSource.propertyKey_serverName, serverName);
        ds.getProperties().setProperty(DB2XADataSource.propertyKey_portNumber, String.valueOf(port));
        ds.getProperties().setProperty(DB2XADataSource.propertyKey_databaseName, databaseName);
        ds.getProperties().setProperty(DB2XADataSource.propertyKey_driverType, "4");
    } catch (SQLException e) {
        e.printStackTrace();
        throw new ApiException("datasource property error", e);
    }
    return ds;
}
Also used : SQLException(java.sql.SQLException) DB2XADataSource(com.ibm.db2.jcc.DB2XADataSource) ApiException(gov.ca.cwds.rest.api.ApiException)

Example 2 with DB2XADataSource

use of com.ibm.db2.jcc.DB2XADataSource in project API by ca-cwds.

the class XASample method buildDB2DataSource.

private static DB2XADataSource buildDB2DataSource(String user, String password, String serverName, int port, String databaseName) {
    DB2XADataSource ds = new DB2XADataSource();
    ds.setUser(user);
    ds.setPassword(password);
    ds.setServerName(serverName);
    ds.setPortNumber(port);
    ds.setDatabaseName(databaseName);
    ds.setDriverType(4);
    try {
        ds.getProperties().setProperty(DB2XADataSource.propertyKey_serverName, serverName);
        ds.getProperties().setProperty(DB2XADataSource.propertyKey_portNumber, String.valueOf(port));
        ds.getProperties().setProperty(DB2XADataSource.propertyKey_databaseName, databaseName);
        ds.getProperties().setProperty(DB2XADataSource.propertyKey_driverType, "4");
    } catch (SQLException e) {
        e.printStackTrace();
        throw new ApiException("datasource property error", e);
    }
    return ds;
}
Also used : SQLException(java.sql.SQLException) DB2XADataSource(com.ibm.db2.jcc.DB2XADataSource) ApiException(gov.ca.cwds.rest.api.ApiException)

Aggregations

DB2XADataSource (com.ibm.db2.jcc.DB2XADataSource)2 ApiException (gov.ca.cwds.rest.api.ApiException)2 SQLException (java.sql.SQLException)2