ResultSetGenerator { public String compile(final ResultSet rs, final String template) { final InputStream templateStream = this.getClass().getResourceAsStream(template); return compile(rs, templateStream); }  String compile(final ResultSet rs,
                          final String template); String compile(final ResultSet rs,
                          final InputStream templateStream); String compile(final ResultSet rs,
                          final TemplateDataListener listener); void newCell(List<DataListener> listeners,
                        int row,
                        int column,
                        String value,
                        int mergedColStart);  }
@Test public void testResultSet() throws Exception { Class.forName("org.hsqldb.jdbcDriver"); Connection conn = DriverManager.getConnection("jdbc:hsqldb:mem:drools-templates", "sa", ""); try { update("CREATE TABLE cheese_rules ( id INTEGER IDENTITY, persons_age INTEGER, birth_date DATE, cheese_type VARCHAR(256), log VARCHAR(256) )", conn); update("INSERT INTO cheese_rules(persons_age,birth_date,cheese_type,log) VALUES(42, '1950-01-01', 'stilton', 'Old man stilton')", conn); update("INSERT INTO cheese_rules(persons_age,birth_date,cheese_type,log) VALUES(10, '2009-01-01', 'cheddar', 'Young man cheddar')", conn); } catch (SQLException e) { throw new IllegalStateException("Could not initialize in memory database", e); } Statement sta = conn.createStatement(); ResultSet rs = sta.executeQuery("SELECT persons_age, cheese_type, log " + " FROM cheese_rules"); final ResultSetGenerator converter = new ResultSetGenerator(); final String drl = converter.compile(rs, getRulesStream()); System.out.println(drl); sta.close(); KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newByteArrayResource(drl.getBytes()), ResourceType.DRL); assertFalse(kbuilder.hasErrors()); InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addPackages(kbuilder.getKnowledgePackages()); KieSession kSession = kbase.newKieSession(); kSession.insert(new Cheese("stilton", 42)); kSession.insert(new Person("michael", "stilton", 42)); List<String> list = new ArrayList<String>(); kSession.setGlobal("list", list); kSession.fireAllRules(); assertEquals(1, list.size()); }