44OConnection::OConnection(
const SQLHANDLE _pDriverHandle,
ODBCDriver* _pDriver)
46 ,m_aConnectionHandle(nullptr)
47 ,m_pDriverHandleCopy(_pDriverHandle)
51 ,m_bUseOldDateFormat(false)
52 ,m_bIgnoreDriverPrivileges(false)
53 ,m_bPreventGetVersionColumns(false)
71 OSL_ENSURE( rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO,
"Failure from SQLDisconnect" );
75 OSL_ENSURE( rc == SQL_SUCCESS ,
"Failure from SQLFreeHandle for connection");
82 OSL_ENSURE(
m_xDriver,
"OConnection::getOdbcFunction: m_xDriver is null!");
83 return m_xDriver->getOdbcFunction(_nIndex);
88 ::osl::MutexGuard aGuard(
m_aMutex );
93 SQLRETURN nSQLRETURN = 0;
96 SQLSMALLINT cbConnStrOut;
98 memcpy(szConnStrIn, aConStr.getStr(), std::min<sal_Int32>(sal_Int32(2048),aConStr.getLength()));
111 static_cast<SQLSMALLINT
>(std::min(sal_Int32(2048),aConStr.getLength())),
115 SQL_DRIVER_NOPROMPT);
116 if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA || SQL_SUCCESS_WITH_INFO == nSQLRETURN)
120 SQLUSMALLINT nSilent = bSilent ? SQL_DRIVER_NOPROMPT : SQL_DRIVER_COMPLETE;
124 static_cast<SQLSMALLINT
>(std::min<sal_Int32>(sal_Int32(2048),aConStr.getLength())),
126 SQLSMALLINT(
sizeof szConnStrOut),
129 if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA)
173 throw SQLException();
175 sal_Int32 nLen = url.indexOf(
':');
176 nLen = url.indexOf(
':',nLen+2);
177 OUString aDSN(
"DSN="), aUID, aPWD, aSysDrvSettings;
178 aDSN += url.subView(nLen+1);
180 sal_Int32 nTimeout = 20;
182 const PropertyValue *pBegin = info.getConstArray();
183 const PropertyValue *pEnd = pBegin + info.getLength();
184 for(;pBegin != pEnd;++pBegin)
186 if( pBegin->Name ==
"Timeout")
188 if( ! (pBegin->Value >>= nTimeout) )
189 SAL_WARN(
"connectivity.odbc",
"Construct: unable to get property Timeout");
191 else if( pBegin->Name ==
"Silent")
193 if( ! (pBegin->Value >>= bSilent) )
194 SAL_WARN(
"connectivity.odbc",
"Construct: unable to get property Silent");
196 else if( pBegin->Name ==
"IgnoreDriverPrivileges")
199 SAL_WARN(
"connectivity.odbc",
"Construct: unable to get property IgnoreDriverPrivileges");
201 else if( pBegin->Name ==
"PreventGetVersionColumns")
204 SAL_WARN(
"connectivity.odbc",
"Construct: unable to get property PreventGetVersionColumns");
206 else if( pBegin->Name ==
"IsAutoRetrievingEnabled")
208 bool bAutoRetrievingEnabled =
false;
209 if( ! (pBegin->Value >>= bAutoRetrievingEnabled) )
210 SAL_WARN(
"connectivity.odbc",
"Construct: unable to get property IsAutoRetrievingEnabled");
213 else if( pBegin->Name ==
"AutoRetrievingStatement")
215 OUString sGeneratedValueStatement;
216 if( ! (pBegin->Value >>= sGeneratedValueStatement) )
217 SAL_WARN(
"connectivity.odbc",
"Construct: unable to get property AutoRetrievingStatement");
220 else if( pBegin->Name ==
"user")
222 if( ! (pBegin->Value >>= aUID) )
223 SAL_WARN(
"connectivity.odbc",
"Construct: unable to get property user");
224 aDSN +=
";UID=" + aUID;
226 else if( pBegin->Name ==
"password")
228 if( ! (pBegin->Value >>= aPWD) )
229 SAL_WARN(
"connectivity.odbc",
"Construct: unable to get property password");
230 aDSN +=
";PWD=" + aPWD;
232 else if( pBegin->Name ==
"UseCatalog")
235 SAL_WARN(
"connectivity.odbc",
"Construct: unable to get property UseCatalog");
237 else if( pBegin->Name ==
"SystemDriverSettings")
239 if( ! (pBegin->Value >>= aSysDrvSettings) )
240 SAL_WARN(
"connectivity.odbc",
"Construct: unable to get property SystemDriverSettings");
241 aDSN +=
";" + aSysDrvSettings;
243 else if( pBegin->Name ==
"CharSet")
246 if( ! (pBegin->Value >>= sIanaName) )
247 SAL_WARN(
"connectivity.odbc",
"Construct: unable to get property CharSet");
251 if (aLookup != aLookupIanaName.
end())
262 if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA)
275 ::osl::MutexGuard aGuard(
m_aMutex );
285 ::osl::MutexGuard aGuard(
m_aMutex );
301 ::osl::MutexGuard aGuard(
m_aMutex );
312 ::osl::MutexGuard aGuard(
m_aMutex );
318 reinterpret_cast<SQLPOINTER
>((autoCommit) ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF) ,SQL_IS_INTEGER),
324 ::osl::MutexGuard aGuard(
m_aMutex );
328 sal_uInt32 nOption = 0;
331 return nOption == SQL_AUTOCOMMIT_ON ;
336 ::osl::MutexGuard aGuard(
m_aMutex );
345 ::osl::MutexGuard aGuard(
m_aMutex );
354 ::osl::MutexGuard aGuard(
m_aMutex );
356 return OConnection_BASE::rBHelper.bDisposed;
361 ::osl::MutexGuard aGuard(
m_aMutex );
376 ::osl::MutexGuard aGuard(
m_aMutex );
393 ::osl::MutexGuard aGuard(
m_aMutex );
405 ::osl::MutexGuard aGuard(
m_aMutex );
409 SQLINTEGER nValueLen;
420 ::osl::MutexGuard aGuard(
m_aMutex );
425 SQL_ATTR_TXN_ISOLATION,
426 reinterpret_cast<SQLPOINTER
>(level),SQL_IS_INTEGER),
432 ::osl::MutexGuard aGuard(
m_aMutex );
437 SQLINTEGER nValueLen;
446 ::osl::MutexGuard aGuard(
m_aMutex );
462 ::osl::MutexGuard aGuard(
m_aMutex );
486 connection.second->dispose();
501 sal_Int32 nMaxStatements =
getMetaData()->getMaxStatements();
506 xConnectionTemp = xConnection;
514 SQLHANDLE aStatementHandle = SQL_NULL_HANDLE;
515 N3SQLAllocHandle(SQL_HANDLE_STMT,xConnectionTemp->getConnection(),&aStatementHandle);
520 return aStatementHandle;
526 if( SQL_NULL_HANDLE == _pHandle )
536 _pHandle = SQL_NULL_HANDLE;
540 aFind->second->dispose();
#define N3SQLFreeHandle(a, b)
#define N3SQLAllocHandle(a, b, c)
#define N3SQLDriverConnect(a, b, c, d, e, f, g, h)
#define N3SQLDisconnect(a)
#define N3SQLFreeStmt(a, b)
#define N3SQLNativeSql(a, b, c, d, e, f)
#define N3SQLSetConnectAttr(a, b, c, d)
#define N3SQLEndTran(a, b, c)
#define N3SQLGetConnectAttr(a, b, c, d, e)
void setAutoRetrievingStatement(const OUString &_sStmt)
void enableAutoRetrievingEnabled(bool _bAutoEnable)
bool m_bIgnoreDriverPrivileges
bool m_bPreventGetVersionColumns
virtual sal_Int32 SAL_CALL getTransactionIsolation() override
virtual void SAL_CALL setTypeMap(const css::uno::Reference< css::container::XNameAccess > &typeMap) override
virtual void SAL_CALL setCatalog(const OUString &catalog) override
virtual void SAL_CALL setAutoCommit(sal_Bool autoCommit) override
virtual void SAL_CALL setTransactionIsolation(sal_Int32 level) override
virtual void SAL_CALL disposing() override
SQLHANDLE m_pDriverHandleCopy
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > SAL_CALL getMetaData() override
OConnection(const SQLHANDLE _pDriverHandle, ODBCDriver *_pDriver)
virtual void SAL_CALL rollback() override
virtual OUString SAL_CALL nativeSQL(const OUString &sql) override
virtual void SAL_CALL close() override
SQLHANDLE m_aConnectionHandle
virtual sal_Bool SAL_CALL isClosed() override
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getTypeMap() override
SQLHANDLE createStatementHandle()
oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareCall(const OUString &sql) override
SQLRETURN Construct(const OUString &url, const css::uno::Sequence< css::beans::PropertyValue > &info)
sal_Int32 m_nStatementCount
virtual ~OConnection() override
virtual void SAL_CALL clearWarnings() override
virtual css::uno::Reference< css::sdbc::XPreparedStatement > SAL_CALL prepareStatement(const OUString &sql) override
virtual sal_Bool SAL_CALL getAutoCommit() override
std::map< SQLHANDLE, rtl::Reference< OConnection > > m_aConnections
virtual void SAL_CALL setReadOnly(sal_Bool readOnly) override
virtual sal_Bool SAL_CALL isReadOnly() override
SQLRETURN OpenConnection(const OUString &aConnectStr, sal_Int32 nTimeOut, bool bSilent)
virtual OUString SAL_CALL getCatalog() override
virtual css::uno::Any SAL_CALL getWarnings() override
rtl::Reference< ODBCDriver > m_xDriver
void freeStatementHandle(SQLHANDLE &_pHandle)
virtual void SAL_CALL commit() override
#define SAL_WARN(area, stream)
void checkDisposed(bool _bThrow)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)