Title: RE: JESS: Database binding

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well since no one else has yet answered this, I'll give it a shot.  Keep in mind though that I've only been using Jess for a couple of weeks so there are no guarantees this is the best advice!

 
My suggestion would be to use the Java Bean interface features of Jess along with a data persistence object library.  Something like JavaBlend, TOPLink, or you could even supply your own.

 
Then you could use defclass and definstance commands to instantiate facts with slots representing cells of the database rows.

 
For instance:
 
class Employee {
    private String name;
    private String boss;
    public Employee() {
        // jdbc calls to read a row and set name/boss or something
    }
    public void setName( String n ) { // jdbc calls to write the name to the db }
    public void setBoss( String b ) {}
    public String getName() { return name; }
    public String getBoss() { return boss; }
    // add a bunch of other stuff here
}
 
Then in jess run
(defclass employee com.yourdomain.Employee)
 
and
(definstance employee ?some-employee-instance)
 
 
for each db row you want to represent as a jess fact.
 
Then you could use these facts in rules LHS and even alter them in RHS actions using (modify ?fact (name "bob")) or something and the data gets automagically written to the db when you're all done!

 
Good luck,
- -Bryan
 

"Our users will know fear and cower before our software!
Ship it! Ship it and let them flee like the dogs they are!"

    -- Morgoth, Klingon programmer 2'nd class



- -----Original Message-----
From: Matteo Melideo [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 19, 2000 1:51 AM
To: JESS
Cc: JESS-Users
Subject: JESS: Database binding


Hi All,
my question now is:
is it possible to bind variable defined in a rule to a DB? If yes how?
 
Bye and thank you
 
- --
Matteo Melideo 
Direct Phone: +39 06 44741145 - Operator: +39 06 4474111
Engineering SpA - R&D Lab -, Fax: +39 06 4465981
Viale del Castro Pretorio, 116 E-mail: [EMAIL PROTECTED] or [EMAIL PROTECTED]
00184 Roma - Italy
- --



-----BEGIN PGP SIGNATURE-----
Version: PGP Personal Privacy 6.5.2

iQA/AwUBOSXzw0zuKKcxAa+OEQIqHACcDeSYtqDqVPHidb4Xizfy79+mB+wAn2g8
Ng0UTlKk63rUoWj/5BfTLwB7
=gymT
-----END PGP SIGNATURE-----

Reply via email to