Hello, On Mon, 22 Nov 1999, Robert Chou wrote: > > Anyone know of, or is working on, a tcljdbc package similar to tclodbc? Later Moses DeJong wrote: > You should not need any kind of tcljdbc wrapper or anything. You can > create jdbc objects directly from Tcl. The whole point of the tcljava > interface is to remove the need to create "wrappers" around C code. > You do not need wrappers when you can just invoke the Java methods > directly from your Tcl code. Let me cite some real code to prove these words. We are using Jacl for a regression test of our Type4 jdbc driver for AdabasD. Here are some typical tests, where you can see that no additional wrapper is needed. The two key points to get things running are the calls of java::call Class forName "de.sag.jdbc.adabasd.ADriver" java::call DriverManager getConnection \ "jdbc:adabasd://$servernode/$serverdb" \ $account $password After this you just use the methods of the $logon, $stmt or $res objects. Note the method call of e.g. getString to get the data of the first column: set out1 [$res {getString int} 1] Without the full signature TclJava would use the getString() method with the String parameter, and this method fails while looking for a column with the name "1" :-( Here the code snippet starts: ------------------------------------------------------------------- if [info exists env(SERVERNODE)] { set servernode $env(SERVERNODE) } else { set servernode localhost } if [info exists env(SERVERDB)] { set serverdb $env(SERVERDB) } else { set serverdb MYDB } if [info exists env(ACCOUNT)] { set account $env(ACCOUNT) } else { set account demo } if [info exists env(PASSWORD)] { set password $env(PASSWORD) } else { set password demo } # The following loading of the adabas driver is a prerequisite; # if it fails, there is no sence in continuing... if {[catch { package require java java::import -package java.sql DriverManager # java::call DriverManager setLogStream [java::field System out] java::call Class forName "de.sag.jdbc.adabasd.ADriver" } msg]} { puts stderr "Loading of the Adabas D jdbc driver failed with message:" puts stderr $msg puts stderr "There seems to be no sense in continuing; exited." exit 1 } test adasql-0.1 {Connect to a warm serverdb} { if {[catch {java::call DriverManager getConnection \ "jdbc:adabasd://$servernode/$serverdb" \ [string toupper $account] \ [string toupper $password]} logon]} { puts stderr \ "The first attempt in this test to connect to serverdb '$serverdb' failed. This may have its reason in the fact, that the Adabas D server has a different name on your machine. Another reason may be, that there exists no account '$account' with the password '$password'. To customize this connect data, set some environment variables: SERVERDB, ACCOUNT and PASSWORD Then you can call this test like the following: SERVERDB=v12 ACCOUNT=krischan PASSWORD=geheim tclsh8.0 all.test The following line is the error message from the database server:" puts stderr $logon exit } set x 1 } 1 test adabas-4 {Errormessages} { set stmt [$logon createStatement] catch {$stmt executeUpdate "DROP TABLE pt"} $stmt executeUpdate {create table pt (a char(20) ascii)} set cmd "create table pt (a char(20) ascii)" set erg [catch {$stmt executeUpdate $cmd} msg] regsub "MESSAGE NOT AVAILABLE" $msg "DUPLICATE TABLE NAME" msg list $erg $msg } {1 {java.sql.SQLException: DUPLICATE TABLE NAME:PT}} test adabas-5 {fetching values} { set res [$stmt executeQuery "select date datum, user benutzer from dual"] $res next set out1 [$res {getString int} 1] set out2 [$res {getString int} 2] regsub -all {[0-9]} $out1 "x" out1 set x ---$out1---$out2--- } [format {---xxxx-xx-xx---%s---} $ACCOUNT] test adabas-6 {Converting Numbers} { set res [$stmt executeQuery {select 1.5+0.025, 4+7, 'a'||'b' from dual}] set rmd [$res getMetaData] $res next set oneahalf [$res {getDouble int} 1] set eleven [$res {getLong int} 2] set ab [$res {getString int} 3] set x "---$oneahalf $eleven $ab---" } {---1.525 11 ab---} ------------------------------------------------------------------------- Message understood? Hth, Krischan -- Christian Krone, SQL Datenbanksysteme GmbH ---------------------------------------------------------------- The TclJava mailing list is sponsored by Scriptics Corporation. To subscribe: send mail to [EMAIL PROTECTED] with the word SUBSCRIBE as the subject. To unsubscribe: send mail to [EMAIL PROTECTED] with the word UNSUBSCRIBE as the subject. To send to the list, send email to '[EMAIL PROTECTED]'.