summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-07-25 16:30:32 +0200
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-07-25 19:41:18 +0200
commit61d4e320301f658eabc918c8b7b731e1890f4531 (patch)
tree56a7b2c7f57fdf0c434ebf0a10caaab755b61c61 /connectivity
parent5249927d9e5f08fb6ac2f99710f4d99bbc366dd1 (diff)
Make evaluateStatusVector a namespace function. (firebird-sdbc)
We're not in java after all... Change-Id: I145fbd7adad5e03a7c9e7bcf28cb2f80ce40ba9e
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/firebird/Blob.cxx18
-rw-r--r--connectivity/source/drivers/firebird/FConnection.cxx44
-rw-r--r--connectivity/source/drivers/firebird/FConnection.hxx9
-rw-r--r--connectivity/source/drivers/firebird/FPreparedStatement.cxx8
-rw-r--r--connectivity/source/drivers/firebird/FResultSet.cxx10
-rw-r--r--connectivity/source/drivers/firebird/FStatement.cxx6
-rw-r--r--connectivity/source/drivers/firebird/Util.cxx31
-rw-r--r--connectivity/source/drivers/firebird/Util.hxx11
8 files changed, 63 insertions, 74 deletions
diff --git a/connectivity/source/drivers/firebird/Blob.cxx b/connectivity/source/drivers/firebird/Blob.cxx
index 12b2622e05c7..8423b2851b00 100644
--- a/connectivity/source/drivers/firebird/Blob.cxx
+++ b/connectivity/source/drivers/firebird/Blob.cxx
@@ -9,6 +9,7 @@
#include "Blob.hxx"
#include "FConnection.hxx"
+#include "Util.hxx"
#include "connectivity/dbexception.hxx"
@@ -52,9 +53,7 @@ void Blob::ensureBlobIsOpened()
0,
NULL);
if (aErr)
- OConnection::evaluateStatusVector(m_statusVector,
- "isc_open_blob2",
- *this);
+ evaluateStatusVector(m_statusVector, "isc_open_blob2", *this);
}
@@ -71,9 +70,7 @@ void SAL_CALL Blob::disposing(void)
{
try
{
- OConnection::evaluateStatusVector(m_statusVector,
- "isc_close_blob",
- *this);
+ evaluateStatusVector(m_statusVector, "isc_close_blob", *this);
}
catch (SQLException e)
{
@@ -105,9 +102,8 @@ sal_Int64 SAL_CALL Blob::length()
aBlobItems,
sizeof(aResultBuffer),
aResultBuffer);
- OConnection::evaluateStatusVector(m_statusVector,
- "isc_blob_info",
- *this);
+
+ evaluateStatusVector(m_statusVector, "isc_blob_info", *this);
if (*aResultBuffer == isc_info_blob_total_length)
{
short aResultLength = (short) isc_vax_integer(aResultBuffer, 2);
@@ -152,9 +148,7 @@ uno::Sequence< sal_Int8 > SAL_CALL Blob::getBytes(sal_Int64 aPosition, sal_Int3
if (aErr)
{
m_blobData = uno::Sequence< sal_Int8 >(0);
- OConnection::evaluateStatusVector(m_statusVector,
- "isc_get_segment",
- *this);
+ evaluateStatusVector(m_statusVector, "isc_get_segment", *this);
}
}
diff --git a/connectivity/source/drivers/firebird/FConnection.cxx b/connectivity/source/drivers/firebird/FConnection.cxx
index d33f9fa96975..12003b200d8d 100644
--- a/connectivity/source/drivers/firebird/FConnection.cxx
+++ b/connectivity/source/drivers/firebird/FConnection.cxx
@@ -34,11 +34,12 @@
*************************************************************************/
#include "FConnection.hxx"
-
#include "FDatabaseMetaData.hxx"
#include "FDriver.hxx"
-#include "FStatement.hxx"
#include "FPreparedStatement.hxx"
+#include "FStatement.hxx"
+#include "Util.hxx"
+
#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
@@ -261,9 +262,7 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
0);
if (aErr)
{
- evaluateStatusVector(status,
- "isc_create_database",
- *this);
+ evaluateStatusVector(status, "isc_create_database", *this);
}
}
else
@@ -276,9 +275,7 @@ void OConnection::construct(const ::rtl::OUString& url, const Sequence< Property
dpbBuffer);
if (aErr)
{
- evaluateStatusVector(status,
- "isc_attach_database",
- *this);
+ evaluateStatusVector(status, "isc_attach_database", *this);
}
}
@@ -731,9 +728,7 @@ void OConnection::disposing()
if (isc_detach_database(status, &m_DBHandler))
{
- evaluateStatusVector(status,
- "isc_detach_database",
- *this);
+ evaluateStatusVector(status, "isc_detach_database", *this);
}
// TODO: write to storage again?
if (m_bIsEmbedded)
@@ -749,31 +744,4 @@ void OConnection::disposing()
cppu::WeakComponentImplHelperBase::disposing();
}
-void SAL_CALL OConnection::evaluateStatusVector( ISC_STATUS_ARRAY& aStatusVector,
- const OUString& aCause,
- const uno::Reference< XInterface >& _rxContext)
- throw(SQLException)
-{
- if (aStatusVector[0]==1 && aStatusVector[1]) // indicates error
- {
- OUStringBuffer buf;
- char msg[512]; // Size is based on suggestion in docs.
- const ISC_STATUS* pStatus = (const ISC_STATUS*) &aStatusVector;
-
- buf.appendAscii("firebird_sdbc error:");
- while(fb_interpret(msg, sizeof(msg), &pStatus))
- {
- // TODO: verify encoding
- buf.appendAscii("\n*");
- buf.append(OUString(msg, strlen(msg), RTL_TEXTENCODING_UTF8));
- }
- buf.appendAscii("\ncaused by\n'").append(aCause).appendAscii("'\n");
-
- OUString error = buf.makeStringAndClear();
- SAL_WARN( "connectivity.firebird", error );
-
- throw SQLException( error, _rxContext, OUString(), 1, Any() );
- }
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/firebird/FConnection.hxx b/connectivity/source/drivers/firebird/FConnection.hxx
index ff8ee91fd83e..8e159239cbeb 100644
--- a/connectivity/source/drivers/firebird/FConnection.hxx
+++ b/connectivity/source/drivers/firebird/FConnection.hxx
@@ -191,15 +191,6 @@ namespace connectivity
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob>
createBlob(ISC_QUAD* pBlobID)
throw(::com::sun::star::sdbc::SQLException);
-
- /**
- * Evaluate a firebird status vector and throw exceptions as necessary.
- * The content of the status vector is included in the thrown exception.
- */
- static void evaluateStatusVector( ISC_STATUS_ARRAY& aStatusVector,
- const ::rtl::OUString& aCause,
- const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext)
- throw (::com::sun::star::sdbc::SQLException);
};
}
}
diff --git a/connectivity/source/drivers/firebird/FPreparedStatement.cxx b/connectivity/source/drivers/firebird/FPreparedStatement.cxx
index acda520e6f37..89c5ef44d741 100644
--- a/connectivity/source/drivers/firebird/FPreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/FPreparedStatement.cxx
@@ -150,9 +150,7 @@ void OPreparedStatement::ensurePrepared()
// }
// }
mallocSQLVAR(m_pInSqlda);
- OConnection::evaluateStatusVector(m_statusVector,
- m_sSqlStatement,
- *this);
+ evaluateStatusVector(m_statusVector, m_sSqlStatement, *this);
}
OPreparedStatement::~OPreparedStatement()
@@ -303,9 +301,7 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery()
if (aErr)
{
SAL_WARN("connectivity.firebird", "isc_dsql_execute failed" );
- OConnection::evaluateStatusVector(m_statusVector,
- "isc_dsql_execute",
- *this);
+ evaluateStatusVector(m_statusVector, "isc_dsql_execute", *this);
}
uno::Reference< OResultSet > pResult(new OResultSet(m_pConnection,
diff --git a/connectivity/source/drivers/firebird/FResultSet.cxx b/connectivity/source/drivers/firebird/FResultSet.cxx
index 082feaee1749..4e0fb53396c2 100644
--- a/connectivity/source/drivers/firebird/FResultSet.cxx
+++ b/connectivity/source/drivers/firebird/FResultSet.cxx
@@ -35,6 +35,8 @@
#include "FResultSet.hxx"
#include "FResultSetMetaData.hxx"
+#include "Util.hxx"
+
#include <propertyids.hxx>
#include <TConnection.hxx>
@@ -125,9 +127,7 @@ sal_Bool SAL_CALL OResultSet::next() throw(SQLException, RuntimeException)
{
SAL_WARN("connectivity.firebird", "Error when populating data");
// Throws sql exception as appropriate
- OConnection::evaluateStatusVector(m_statusVector,
- "isc_dsql_fetch",
- *this);
+ evaluateStatusVector(m_statusVector, "isc_dsql_fetch", *this);
return sal_False;
}
}
@@ -286,9 +286,7 @@ void OResultSet::disposing(void)
&m_statementHandle,
DSQL_drop);
try {
- OConnection::evaluateStatusVector(m_statusVector,
- "isc_dsql_free_statement",
- *this);
+ evaluateStatusVector(m_statusVector, "isc_dsql_free_statement", *this);
}
catch (SQLException e)
{
diff --git a/connectivity/source/drivers/firebird/FStatement.cxx b/connectivity/source/drivers/firebird/FStatement.cxx
index 907e57c9d972..29dea7a6af52 100644
--- a/connectivity/source/drivers/firebird/FStatement.cxx
+++ b/connectivity/source/drivers/firebird/FStatement.cxx
@@ -113,7 +113,7 @@ sal_Int32 SAL_CALL OStatement::executeUpdate(const OUString& sql)
if (aErr)
SAL_WARN("connectivity.firebird", "isc_dsql_execute_immediate failed" );
- m_pConnection->evaluateStatusVector(m_statusVector, sql, *this);
+ evaluateStatusVector(m_statusVector, sql, *this);
// TODO: get number of changed rows with SELECT ROW_COUNT (use executeQuery)
// return getUpdateCount();
return 0;
@@ -158,7 +158,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
// TODO: deal with cleanup
// close();
- m_pConnection->evaluateStatusVector(m_statusVector, sql, *this);
+ evaluateStatusVector(m_statusVector, sql, *this);
return m_xResultSet;
}
@@ -194,7 +194,7 @@ sal_Bool SAL_CALL OStatement::execute(const OUString& sql)
SAL_WARN("connectivity.firebird", "isc_dsql_execute failed" );
}
- m_pConnection->evaluateStatusVector(m_statusVector, sql, *this);
+ evaluateStatusVector(m_statusVector, sql, *this);
// returns true when a resultset is available
return sal_False;
diff --git a/connectivity/source/drivers/firebird/Util.cxx b/connectivity/source/drivers/firebird/Util.cxx
index bc77775e4d90..f8259de7e954 100644
--- a/connectivity/source/drivers/firebird/Util.cxx
+++ b/connectivity/source/drivers/firebird/Util.cxx
@@ -9,11 +9,42 @@
#include "Util.hxx"
+#include <rtl/ustrbuf.hxx>
+
using namespace ::connectivity;
using namespace ::rtl;
+using namespace ::com::sun::star;
using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+
+void firebird::evaluateStatusVector(ISC_STATUS_ARRAY& aStatusVector,
+ const OUString& aCause,
+ const uno::Reference< XInterface >& _rxContext)
+ throw(SQLException)
+{
+ if (aStatusVector[0]==1 && aStatusVector[1]) // indicates error
+ {
+ OUStringBuffer buf;
+ char msg[512]; // Size is based on suggestion in docs.
+ const ISC_STATUS* pStatus = (const ISC_STATUS*) &aStatusVector;
+
+ buf.appendAscii("firebird_sdbc error:");
+ while(fb_interpret(msg, sizeof(msg), &pStatus))
+ {
+ // TODO: verify encoding
+ buf.appendAscii("\n*");
+ buf.append(OUString(msg, strlen(msg), RTL_TEXTENCODING_UTF8));
+ }
+ buf.appendAscii("\ncaused by\n'").append(aCause).appendAscii("'\n");
+
+ OUString error = buf.makeStringAndClear();
+ SAL_WARN("connectivity.firebird", error);
+
+ throw SQLException( error, _rxContext, OUString(), 1, Any() );
+ }
+}
sal_Int32 firebird::getColumnTypeFromFBType(short aType)
{
diff --git a/connectivity/source/drivers/firebird/Util.hxx b/connectivity/source/drivers/firebird/Util.hxx
index f3039dbcdc51..664a17d008c3 100644
--- a/connectivity/source/drivers/firebird/Util.hxx
+++ b/connectivity/source/drivers/firebird/Util.hxx
@@ -15,11 +15,22 @@
#include <rtl/ustring.hxx>
#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/SQLException.hpp>
namespace connectivity
{
namespace firebird
{
+
+ /**
+ * Evaluate a firebird status vector and throw exceptions as necessary.
+ * The content of the status vector is included in the thrown exception.
+ */
+ void evaluateStatusVector(ISC_STATUS_ARRAY& aStatusVector,
+ const ::rtl::OUString& aCause,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext)
+ throw (::com::sun::star::sdbc::SQLException);
+
sal_Int32 getColumnTypeFromFBType(short aType);
::rtl::OUString getColumnTypeNameFromFBType(short aType);