Db2

 View Only
  • 1.  datasource

    Posted Mon June 22, 2020 05:08 PM
    Hi all, 
    i'm new to db2, so may be my problem is easy (I also do not know if this one is the right place to post this issue;

    I have to configure a datasource in my java class; I did it in oracle quite easy:

    @Bean
    public DataSource dataSource() {
    		Properties connProps = new Properties(); 
    		try {
    			OracleDataSource ods = new OracleDataSource();
    			connProps.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, environment.getRequiredProperty("jdbc.username"));
    			connProps.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, environment.getRequiredProperty("jdbc.password")); 
    			
    			ods.setURL(environment.getRequiredProperty("jdbc.url"));
    			ods.setConnectionProperties(connProps);
    			return ods;
    		} catch (SQLException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    			return null;
    		} 
    	}





    I need the "equivalent" class for setting a datasource with DB2; But i wasn't able to find out;
    I try to use this one DB2ConnectionPoolDataSource ds = new DB2ConnectionPoolDataSource();
    but it cannot be cast to  javax.sql.DataSource

    I can't believe that there is no way to create a datasource with DB2.

    every help is appreciate thanks a lot.

    ------------------------------
    francesco Viscomi
    ------------------------------

    #Db2