mysqlc_driver.cxx (cdf0e10c) mysqlc_driver.cxx (24687b4c)
1/*************************************************************************
2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3*
4* Copyright 2008 by Sun Microsystems, Inc.
5*
6* OpenOffice.org - a multi-platform office productivity suite
7*
8* $RCSfile: mysqlc_driver.cxx,v $

--- 26 unchanged lines hidden (view full) ---

35using namespace com::sun::star::beans;
36using namespace com::sun::star::sdbc;
37using namespace connectivity::mysqlc;
38using ::rtl::OUString;
39#include <stdio.h>
40
41#include <preextstl.h>
42#include <cppconn/exception.h>
1/*************************************************************************
2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3*
4* Copyright 2008 by Sun Microsystems, Inc.
5*
6* OpenOffice.org - a multi-platform office productivity suite
7*
8* $RCSfile: mysqlc_driver.cxx,v $

--- 26 unchanged lines hidden (view full) ---

35using namespace com::sun::star::beans;
36using namespace com::sun::star::sdbc;
37using namespace connectivity::mysqlc;
38using ::rtl::OUString;
39#include <stdio.h>
40
41#include <preextstl.h>
42#include <cppconn/exception.h>
43#ifdef SYSTEM_MYSQL_CPPCONN
44 #include <mysql_driver.h>
45#endif
43#include <mysql_driver.h>
46#include <postextstl.h>
47
48
49/* {{{ MysqlCDriver::MysqlCDriver() -I- */
50MysqlCDriver::MysqlCDriver(const Reference< XMultiServiceFactory >& _rxFactory)
51 : ODriver_BASE(m_aMutex)
52 ,m_xFactory(_rxFactory)
44#include <postextstl.h>
45
46
47/* {{{ MysqlCDriver::MysqlCDriver() -I- */
48MysqlCDriver::MysqlCDriver(const Reference< XMultiServiceFactory >& _rxFactory)
49 : ODriver_BASE(m_aMutex)
50 ,m_xFactory(_rxFactory)
53#ifndef SYSTEM_MYSQL_CPPCONN
54 ,m_hCppConnModule( NULL )
55 ,m_bAttemptedLoadCppConn( false )
56#endif
57{
58 OSL_TRACE("MysqlCDriver::MysqlCDriver");
59 cppDriver = NULL;
60}
61/* }}} */
62
63
64/* {{{ MysqlCDriver::disposing() -I- */

--- 76 unchanged lines hidden (view full) ---

141}
142/* }}} */
143
144
145extern "C" { static void SAL_CALL thisModule() {} }
146
147void MysqlCDriver::impl_initCppConn_lck_throw()
148{
51{
52 OSL_TRACE("MysqlCDriver::MysqlCDriver");
53 cppDriver = NULL;
54}
55/* }}} */
56
57
58/* {{{ MysqlCDriver::disposing() -I- */

--- 76 unchanged lines hidden (view full) ---

135}
136/* }}} */
137
138
139extern "C" { static void SAL_CALL thisModule() {} }
140
141void MysqlCDriver::impl_initCppConn_lck_throw()
142{
149#ifdef SYSTEM_MYSQL_CPPCONN
150 cppDriver = get_driver_instance();
143 cppDriver = get_driver_instance();
151#else
152 if ( !m_bAttemptedLoadCppConn )
153 {
154 const ::rtl::OUString sModuleName = ::rtl::OUString::createFromAscii( CPPCONN_LIB );
155 m_hCppConnModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 );
156 m_bAttemptedLoadCppConn = true;
157 }
158
159 // attempted to load - was it successful?
160 if ( !m_hCppConnModule )
161 {
162 OSL_ENSURE( false, "MysqlCDriver::impl_initCppConn_lck_throw: could not load the " CPPCONN_LIB " library!");
163 throw SQLException(
164 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unable to load the " CPPCONN_LIB " library." ) ),
165 *this,
166 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "08001" ) ), // "unable to connect"
167 0,
168 Any()
169 );
170 }
171
172 // find the factory symbol
173 const ::rtl::OUString sSymbolName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "sql_mysql_get_driver_instance" ) );
174 typedef void* (* FGetMySQLDriver)();
175
176 const FGetMySQLDriver pFactoryFunction = (FGetMySQLDriver)( osl_getFunctionSymbol( m_hCppConnModule, sSymbolName.pData ) );
177 if ( !pFactoryFunction )
178 {
179 OSL_ENSURE( false, "MysqlCDriver::impl_initCppConn_lck_throw: could not find the factory symbol in " CPPCONN_LIB "!");
180 throw SQLException(
181 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CPPCONN_LIB " is invalid: missing the driver factory function." ) ),
182 *this,
183 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "08001" ) ), // "unable to connect"
184 0,
185 Any()
186 );
187 }
188
189 cppDriver = static_cast< sql::Driver* >( (*pFactoryFunction)() );
190#endif
191 if ( !cppDriver )
192 {
193 throw SQLException(
194 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unable to obtain the MySQL_Driver instance from Connector/C++." ) ),
195 *this,
196 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "08001" ) ), // "unable to connect"
197 0,
198 Any()

--- 171 unchanged lines hidden ---
144 if ( !cppDriver )
145 {
146 throw SQLException(
147 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unable to obtain the MySQL_Driver instance from Connector/C++." ) ),
148 *this,
149 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "08001" ) ), // "unable to connect"
150 0,
151 Any()

--- 171 unchanged lines hidden ---