[rules-users] Dependency Enumeration List in Drools

srinivasasanda srinivasasanda at gmail.com
Mon Dec 12 04:41:38 EST 2011


Thank you.I referred and succeeded almost,but unable to retrieve the state
list.Here is mycode.

*Enumeration file*

*'Address.country' : (new com.sample.DataList()).getMycountryList()
'Address.state[country]' : '(new
com.sample.DataList()).getListOfStates("@{country}")'*

Here When I select country list,and after that when I select USA.the
getListOfStates function is being called..
 public List<String> getListOfStates(String country) throws SQLException,
ClassNotFoundException {

            List<String> list = new ArrayList<String>(0);
           System.out.println(country);
            Class.forName("com.mysql.jdbc.Driver");
	        Connection conn = null;
			try {
				conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/drools","root","mysql");
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	        PreparedStatement pst=null;
	        Statement stt=null;
if("USA".equalsIgnoreCase(country))
{
	
	      System.out.println("In function");
	        stt=conn.createStatement();
	        String qry1="select state from india";
	        ResultSet rs1=stt.executeQuery(qry1);
	   
	        while(rs1.next())
	        {
	        	String s=rs1.getString(1);
	        
	    		list.add(s);
	        	
	        }
}
else
{
	
}
		System.out.println(list);
		return list;
    }

In my server console Iam able to see states list as Newyork,washignton
etc..But,In rule I unable to load states list..The list is not getting
retrieved even the function is successfuly called and executed.Should i need
to include any code in enumeration to achieve this?Please suggest me

--
View this message in context: http://drools.46999.n3.nabble.com/Dependency-Enumeration-List-in-Drools-tp3578864p3579033.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list