Hi every body i am new to Drools section . What i want to achive in drool
let me axplain with example.
When
Price==$price
then
// some code
what we are trying to do is some how value of $price comes from
database.rather hard coding it
what i have did
1. Using jboss developer studio for developing Drool Application
2. Using MySql DataBase
3. My Class File
public static class Applicant {
//public static final int HELLO = 0;
//public static final int GOODBYE = 1;
private String Name;
private int Price;
//private String message;
//private int status;
public String getName()
{
return this.Name;
}
public void setName( String name)
{
this.Name=name;
}
public int getPrice()
{
return this.Price;
}
public void setPrice(int price)
{
this.Price=price;
}
public String GetData()
{
String p=null;
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("my connection info ");
if(!con.isClosed())
System.out.println("Successfully connected to " +
"MySQL server using TCP/IP...");
} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
}
try{
Statement smt=con.createStatement();
ResultSet rs=smt.executeQuery("select ItenPrice from Item Where
ItemId= 1");
while(rs.next())
{
p=rs.getString("ItenPrice");
}
}
catch(Exception a)
{
System.err.println("Exception: " + a.getMessage());
}
return p;
}
public void GetNewdata(Applicant Ap)
{
Ap.GetData();
}
/*
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public int getStatus() {
return this.status;
}
public void setStatus(int status) {
this.status = status;
}*/
}
4. My drools File
package com.sample
import com.sample.DroolsTest.Applicant;
rule "Hello World"
when
A:Applicant( price<20 )
then
String a=A.GetData();
System.out.println( a );
end
5. what i want in when section insted of writing 20 i can write GetData()
which is returning value from data base, it is working fine in then section
but firing error in when section
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/DataBase-Configuratio...
Sent from the Drools - User mailing list archive at
Nabble.com.