summaryrefslogtreecommitdiff
path: root/libodbcpp/connection.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-07-05 15:13:40 +0000
committerrandomdan <randomdan@localhost>2010-07-05 15:13:40 +0000
commit033b3a170b6007e2b954940fb4f4779e50cee012 (patch)
tree3a120822928c3230cca52dea5922cc26a29c2ea5 /libodbcpp/connection.cpp
parentUse cgicc, add checks, tasks, dynamic loader, atom feed, login page (diff)
downloadlibdbpp-odbc-033b3a170b6007e2b954940fb4f4779e50cee012.tar.bz2
libdbpp-odbc-033b3a170b6007e2b954940fb4f4779e50cee012.tar.xz
libdbpp-odbc-033b3a170b6007e2b954940fb4f4779e50cee012.zip
Implement connection caching and checking (requires ODBCv3 driver)
Implement preferLocal DB access
Diffstat (limited to 'libodbcpp/connection.cpp')
-rw-r--r--libodbcpp/connection.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/libodbcpp/connection.cpp b/libodbcpp/connection.cpp
index 6adcf09..03bf813 100644
--- a/libodbcpp/connection.cpp
+++ b/libodbcpp/connection.cpp
@@ -1,5 +1,6 @@
#include <sqlext.h>
#include <syslog.h>
+#include <pcap.h>
#include "connection.h"
#include "error.h"
@@ -52,7 +53,7 @@ ODBC::Connection::Connection(const std::string & s) :
throw Error(dberr, SQL_HANDLE_ENV, env, "Allocate handle");
}
- dberr = SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC2, 0);
+ dberr = SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
if ((dberr != SQL_SUCCESS)) {
throw Error(dberr, SQL_HANDLE_ENV, env, "Set ODBC version");
}
@@ -171,3 +172,26 @@ ODBC::Connection::inTx() const
return (txDepth > 0);
}
+std::string
+ODBC::Connection::getAttrStr(SQLINTEGER attr) const
+{
+ unsigned char buf[BUFSIZ];
+ SQLINTEGER size = 0;
+ SQLINTEGER rc = SQLGetConnectAttr(conn, attr, buf, BUFSIZ, &size);
+ if (rc != SQL_SUCCESS) {
+ throw ODBC::Error(rc, SQL_HANDLE_DBC, conn, "%s", __FUNCTION__);
+ }
+ return std::string((const char *)buf, size);
+}
+
+SQLINTEGER
+ODBC::Connection::getAttrInt(SQLINTEGER attr) const
+{
+ SQLINTEGER result;
+ SQLINTEGER rc = SQLGetConnectAttr(conn, attr, &result, sizeof(result), 0);
+ if (rc != SQL_SUCCESS) {
+ throw ODBC::Error(rc, SQL_HANDLE_DBC, conn, "%s", __FUNCTION__);
+ }
+ return result;
+}
+