summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Fernandez <jfernandez@igalia.com>2013-05-27 12:27:23 +0000
committerJavier Fernandez <jfernandez@igalia.com>2013-06-06 09:37:42 +0000
commitc7a726ef2846aa430d5e0e4d3841658b3f94eaa8 (patch)
tree2bf0620648c2f72cc8915437ceb30894ae5fc9e3
parent2be7f51d14a9c5c09ed310dea5058e72eadbd712 (diff)
Properly implementing the connection construction.
Change-Id: I6bb114d871697483a1a4246496f73252e5307534
-rw-r--r--connectivity/source/drivers/firebird/FConnection.cxx74
-rw-r--r--connectivity/source/drivers/firebird/FConnection.hxx6
2 files changed, 35 insertions, 45 deletions
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index d4948295e0dc..4f98cd1cfb36 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -45,6 +45,7 @@
#include <com/sun/star/lang/DisposedException.hpp>
using namespace connectivity::firebird;
+using namespace connectivity;
//------------------------------------------------------------------------------
using namespace com::sun::star::uno;
@@ -62,6 +63,7 @@ OConnection::OConnection(FirebirdDriver* _pDriver)
m_bUseOldDateFormat(sal_False)
{
m_pDriver->acquire();
+ m_DBHandler = NULL;
}
//-----------------------------------------------------------------------------
OConnection::~OConnection()
@@ -78,56 +80,40 @@ void SAL_CALL OConnection::release() throw()
}
// -----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+
+/* Print the status, the SQLCODE, and exit.
+ * Also, indicate which operation the error occured on.
+ */
+static int pr_error (long* status, char* operation)
+{
+ printf("[\n");
+ printf("PROBLEM ON \"%s\".\n", operation);
+
+ isc_print_status(status);
+
+ printf("SQLCODE:%d\n", isc_sqlcode(status));
+
+ printf("]\n");
+
+ return 1;
+}
+
void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException)
{
+ printf("DEBUG !!! connectivity.firebird", "=> OConnection::construct()" );
+
osl_atomic_increment( &m_refCount );
// some example code how to get the information out of the sequence
- sal_Int32 nLen = url.indexOf(':');
- nLen = url.indexOf(':',nLen+1);
- ::rtl::OUString aDSN("DSN="), aUID, aPWD, aSysDrvSettings;
- aDSN += url.copy(nLen+1);
-
- const char* pUser = "user";
- const char* pTimeout = "Timeout";
- const char* pSilent = "Silent";
- const char* pPwd = "password";
- const char* pUseCatalog = "UseCatalog";
- const char* pSysDrv = "SystemDriverSettings";
-
- sal_Int32 nTimeout = 20;
- sal_Bool bSilent = sal_True;
- const PropertyValue *pBegin = info.getConstArray();
- const PropertyValue *pEnd = pBegin + info.getLength();
- for(;pBegin != pEnd;++pBegin)
- {
- if(!pBegin->Name.compareToAscii(pTimeout))
- pBegin->Value >>= nTimeout;
- else if(!pBegin->Name.compareToAscii(pSilent))
- pBegin->Value >>= bSilent;
- else if(!pBegin->Name.compareToAscii(pUser))
- {
- pBegin->Value >>= aUID;
- aDSN = aDSN + ::rtl::OUString(";UID=") + aUID;
- }
- else if(!pBegin->Name.compareToAscii(pPwd))
- {
- pBegin->Value >>= aPWD;
- aDSN = aDSN + ::rtl::OUString(";PWD=") + aPWD;
- }
- else if(!pBegin->Name.compareToAscii(pUseCatalog))
- {
- pBegin->Value >>= m_bUseCatalog;
- }
- else if(!pBegin->Name.compareToAscii(pSysDrv))
- {
- pBegin->Value >>= aSysDrvSettings;
- aDSN += ::rtl::OUString(";");
- aDSN += aSysDrvSettings;
- }
- }
- m_sUser = aUID;
+ ISC_STATUS_ARRAY status; /* status vector */
+ isc_db_handle db = NULL; /* database handle */
+
+ if (isc_attach_database(status, 0, "/home/javi/Firebird/test/new.fdb", &db, 0, NULL))
+ if (pr_error(status, "attach database"))
+ return;
+
+ m_DBHandler = db;
osl_atomic_decrement( &m_refCount );
}
diff --git a/connectivity/source/drivers/firebird/FConnection.hxx b/connectivity/source/drivers/firebird/FConnection.hxx
index 2f3b96ace57c..dc4b62be9144 100644
--- a/connectivity/source/drivers/firebird/FConnection.hxx
+++ b/connectivity/source/drivers/firebird/FConnection.hxx
@@ -50,6 +50,8 @@
#include <map>
+#include <ibase.h>
+
namespace connectivity
{
namespace firebird
@@ -64,6 +66,7 @@ namespace connectivity
class FirebirdDriver;
class ODatabaseMetaData;
+
typedef OMetaConnection_BASE OConnection_BASE; // implements basics and text encoding
typedef ::std::vector< ::connectivity::OTypeInfo> TTypeInfoVector;
typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray;
@@ -99,7 +102,7 @@ namespace connectivity
sal_Bool m_bClosed;
sal_Bool m_bUseCatalog; // should we use the catalog on filebased databases
sal_Bool m_bUseOldDateFormat;
-
+ isc_db_handle m_DBHandler;
void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException);
@@ -147,6 +150,7 @@ namespace connectivity
// should we use the catalog on filebased databases
inline sal_Bool isCatalogUsed() const { return m_bUseCatalog; }
inline ::rtl::OUString getUserName() const { return m_sUser; }
+ inline isc_db_handle getDBHandler() const { return m_DBHandler; }
inline FirebirdDriver* getDriver() const { return m_pDriver;}
inline rtl_TextEncoding getTextEncoding() const { return m_nTextEncoding; }
};