X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=db-db2%2Fdb2-sql.lisp;h=aa7901e018a3fc405629c452d84383955afb9551;hp=16aa2165cf3613808749948aa2b7440843f2b237;hb=906d7a71b35ee1cd6d281623694bc90ced22c339;hpb=44cd3f817f6f59ffe495db4cf2b9ea4637a57f75 diff --git a/db-db2/db2-sql.lisp b/db-db2/db2-sql.lisp index 16aa216..aa7901e 100644 --- a/db-db2/db2-sql.lisp +++ b/db-db2/db2-sql.lisp @@ -4,8 +4,6 @@ ;;;; ;;;; Name: db2-sql.lisp ;;;; -;;;; $Id$ -;;;; ;;;; This file is part of CLSQL. ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software @@ -24,7 +22,7 @@ (defmethod database-name-from-spec (connection-spec - (database-type (eql :db2))) + (database-type (eql :db2))) (check-connection-spec connection-spec database-type (dsn user password)) (destructuring-bind (dsn user password) connection-spec (declare (ignore password)) @@ -34,16 +32,16 @@ (check-connection-spec connection-spec database-type (dsn user password)) (destructuring-bind (server user password) connection-spec (handler-case - (let ((db (make-instance 'db2-database - :name (database-name-from-spec connection-spec :db2) - :database-type :db2))) - (db2-connect db server user password) - db) - (error () ;; Init or Connect failed - (error 'sql-connection-error - :database-type database-type - :connection-spec connection-spec - :message "Connection failed"))))) + (let ((db (make-instance 'db2-database + :name (database-name-from-spec connection-spec :db2) + :database-type :db2))) + (db2-connect db server user password) + db) + (error () ;; Init or Connect failed + (error 'sql-connection-error + :database-type database-type + :connection-spec connection-spec + :message "Connection failed"))))) ;; API Functions @@ -55,18 +53,18 @@ `(the handle-type (uffi:deref-pointer (the handle-ptr-type ,foreign-object) cli-handle))) (defun db2-connect (db server user password) - (let ((henv (uffi:allocate-foreign-object cli-handle)) - (hdbc (uffi:allocate-foreign-object cli-handle))) + (let ((henv (uffi:allocate-foreign-object 'cli-handle)) + (hdbc (uffi:allocate-foreign-object 'cli-handle))) (sql-alloc-handle SQL_HANDLE_ENV SQL_NULL_HANDLE henv) (setf (slot-value db 'henv) henv) (setf (slot-value db 'hdbc) hdbc) - + (sql-alloc-handle SQL_HANDLE_DBC (deref-vp henv) hdbc) (uffi:with-cstrings ((native-server server) - (native-user user) - (native-password password)) + (native-user user) + (native-password password)) (sql-connect (deref-vp hdbc) - native-server SQL_NTS - native-user SQL_NTS - native-password SQL_NTS))) + native-server SQL_NTS + native-user SQL_NTS + native-password SQL_NTS))) db)