hello,

can i insert data to database through JESS? i want to insert data on
working memory to the database. first i used defquery to choose data which
i want to insert into database.
i have tried to select data in database with JESS and i can do it
successfully. but why when i tried to insert data i failed? im using
microsoft access 2003.

this is the code when i select data :

Jess> (import java.sql.*)
TRUE
Jess> (call Class forName sun.jdbc.odbc.JdbcOdbcDriver)
<Java-Object:java.lang.Class>
Jess> (bind ?conn (call DriverManager getConnection
"jdbc:odbc:databaseTest"))
<Java-Object:sun.jdbc.odbc.JdbcOdbcConnection>
Jess> (bind ?statement (?conn createStatement))
<Java-Object:sun.jdbc.odbc.JdbcOdbcStatement>
Jess> (bind ?rs (?statement executeQuery  "select * from pakar"))
<Java-Object:sun.jdbc.odbc.JdbcOdbcResultSet>
Jess> (while (?rs next) do
(printout t (?rs getString nama) " " (?rs getString jabatan) crlf))
java pakar
jess pakar
test conn pakar
hello world pakar
john doe pakar
tom riddle pakar
vivi pakar
admin admin
FALSE
Jess> (?statement close)
Jess> (?conn close)<br>
Jess> <br>
Jess>

and this is when i insert data, if i wrong in syntax, can you help me to
fix it.


Jess> (defquery search
        (declare (variables ?x))
        (color ?x ?y))
TRUE
Jess> (deffacts data
  (color blue red)
  (color blue green)
  (color blue pink)
  (color red blue)
  (color blue blue)
  (color orange yellow)
  (warna blue purple))
TRUE
Jess> (reset)
TRUE
Jess> (facts)
f-0   (MAIN::initial-fact)
f-1   (MAIN::color blue red)
f-2   (MAIN::color blue green)
f-3   (MAIN::color blue pink)
f-4   (MAIN::color red blue)
f-5   (MAIN::color blue blue)
f-6   (MAIN::color orange yellow)
f-7   (MAIN::warna blue purple)
For a total of 8 facts in module MAIN.
Jess> (bind ?result (run-query* search blue))
<Java-Object:jess.QueryResult>
Jess> (while (?result next)
(printout t (?result getString x)" "(?result getString y) crlf))
blue red
blue green
blue pink
blue blue
FALSE
Jess> (import java.sql.*)
TRUE
Jess> (call Class forName sun.jdbc.odbc.JdbcOdbcDriver)
<Java-Object:java.lang.Class>
Jess> (bind ?conn (call DriverManager getConnection
"jdbc:odbc:databaseTest"))
<Java-Object:sun.jdbc.odbc.JdbcOdbcConnection>
Jess> (bind ?statement (?conn createStatement))
<Java-Object:sun.jdbc.odbc.JdbcOdbcStatement>
Jess> (bind ?result (run-query* search blue))
<Java-Object:jess.QueryResult>
Jess> (while (?result next)
(printout t (?result getString x)" "(?result getString y) crlf))
blue red
blue green
blue pink
blue blue
FALSE
Jess> (facts)
f-0   (MAIN::initial-fact)
f-1   (MAIN::color blue red)
f-2   (MAIN::color blue green)
f-3   (MAIN::color blue pink)
f-4   (MAIN::color red blue)
f-5   (MAIN::color blue blue)
f-6   (MAIN::color orange yellow)
f-7   (MAIN::warna blue purple)
For a total of 8 facts in module MAIN.
Jess> (while (?result next)
(?statement execute  "insert into test (persen) values (?result getString
y)"))
FALSE
Jess>

and the content in database is still blank.



in different way i got this error :


Jess> (while (?result next)
(?statement execute  "insert into test (persen) values (?result getString
z)"))
Jess reported an error in routine Context.getReturn
        while executing (call ?statement execute "insert into test
(persen) valu
es (?result getString z)")
        while executing (while (call ?result next) (call ?statement
execute "ins
ert into test (persen) values (?result getString z)")).
  Message: No such variable statement.
  Program text: ( while ( ?result next ) ( ?statement execute "insert into
test
(persen) values (?result getString z)" ) )  at line 282.


please help me to fix it, thank you.


regards,

vivi




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to