public void testCreatePool() throws Exception { final ObjectFactory objectFactory = ClassicEngineBoot.getInstance().getObjectFactory(); final IDatabaseDialectService dialectService = objectFactory.get(IDatabaseDialectService.class); final DatabaseTypeHelper databaseTypeHelper = new DatabaseTypeHelper(dialectService.getDatabaseTypes()); final DatabaseConnection con = new DatabaseConnection(); con.setId("Memory"); con.setName("Memory"); con.setAccessType(DatabaseAccessType.NATIVE); con.setDatabaseType(databaseTypeHelper.getDatabaseTypeByShortName("GENERIC")); con.setUsername("pentaho_user"); con.setPassword("password"); final HashMap<String, String> attrs = new HashMap<String, String>(); attrs.put(DatabaseConnection.ATTRIBUTE_CUSTOM_DRIVER_CLASS, "org.hsqldb.jdbcDriver"); attrs.put(DatabaseConnection.ATTRIBUTE_CUSTOM_URL, "jdbc:hsqldb:mem:SampleData"); con.setAttributes(attrs); final PoolingDataSource poolingDataSource = PooledDatasourceHelper.setupPooledDataSource(con); final Connection connection = poolingDataSource.getConnection(); connection.close(); }
/** * This method handles the resource-like loading of the XUL fragment definitions based on * connection type and access method. If there is a common definition, and no connection specific * override definition, then the common definition is used. Connection specific definition * resources follow the naming pattern [connection type code]_[access method].xul. */ public void refreshOptionsWithCallback(final IFragmentHandler.Callback callback) { connectionBox = (XulListbox) document.getElementById("connection-type-list"); // $NON-NLS-1$ accessBox = (XulListbox) document.getElementById("access-type-list"); // $NON-NLS-1$ String connectionKey = getSelectedString(connectionBox); if (connectionKey == null) { return; } // DatabaseInterface database = DataHandler.connectionMap.get(connectionKey); IDatabaseType database = databaseTypeHelper.getDatabaseTypeByName(connectionKey); String accessKey = getSelectedString(accessBox); DatabaseAccessType access = DatabaseAccessType.getAccessTypeByName(accessKey); if (access == null) { return; } String fragment = null; DataHandler dataHandler = null; try { dataHandler = (DataHandler) xulDomContainer.getEventHandler("dataHandler"); // $NON-NLS-1$ dataHandler.pushCache(); } catch (XulException e) { // TODO not a critical function, but should log a problem... } switch (access) { case JNDI: fragment = getFragment(database, "_jndi.xul", "common_jndi.xul"); // $NON-NLS-1$ //$NON-NLS-2$ break; case NATIVE: fragment = getFragment(database, "_native.xul", "common_native.xul"); // $NON-NLS-1$ //$NON-NLS-2$ break; case OCI: fragment = getFragment(database, "_oci.xul", "common_native.xul"); // $NON-NLS-1$ //$NON-NLS-2$ break; case ODBC: fragment = getFragment(database, "_odbc.xul", "common_odbc.xul"); // $NON-NLS-1$ //$NON-NLS-2$ break; case PLUGIN: fragment = getFragment(database, "_plugin.xul", "common_native.xul"); // $NON-NLS-1$ //$NON-NLS-2$ break; } try { loadDatabaseOptionsFragment(fragment.toLowerCase(), dataHandler, database, callback); } catch (XulException e) { // TODO should be reporting as an error dialog; need error dialog in XUL framework showMessage( messages.getString( "FragmentHandler.USER.CANT_LOAD_OPTIONS", database.getName()) // $NON-NLS-1$ ); } }