summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libodbcpp/connection.cpp26
-rw-r--r--libodbcpp/connection.h3
2 files changed, 28 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;
+}
+
diff --git a/libodbcpp/connection.h b/libodbcpp/connection.h
index b89a5f9..82caf22 100644
--- a/libodbcpp/connection.h
+++ b/libodbcpp/connection.h
@@ -19,6 +19,9 @@ namespace ODBC {
void abortTx() const;
bool txIsAborted() const;
bool inTx() const;
+ std::string getAttrStr(SQLINTEGER) const;
+ SQLINTEGER getAttrInt(SQLINTEGER) const;
+
private:
mutable unsigned int txDepth;
mutable bool txAborted;