xref: /trunk/main/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
134dd1e25SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
334dd1e25SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
434dd1e25SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
534dd1e25SAndrew Rist  * distributed with this work for additional information
634dd1e25SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
734dd1e25SAndrew Rist  * to you under the Apache License, Version 2.0 (the
834dd1e25SAndrew Rist  * "License"); you may not use this file except in compliance
934dd1e25SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
1134dd1e25SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
1334dd1e25SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1434dd1e25SAndrew Rist  * software distributed under the License is distributed on an
1534dd1e25SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1634dd1e25SAndrew Rist  * KIND, either express or implied.  See the License for the
1734dd1e25SAndrew Rist  * specific language governing permissions and limitations
1834dd1e25SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
2034dd1e25SAndrew Rist  *************************************************************/
2134dd1e25SAndrew Rist 
2234dd1e25SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "SConnection.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "SDatabaseMetaData.hxx"
27cdf0e10cSrcweir #include "SDriver.hxx"
28cdf0e10cSrcweir #include "SStatement.hxx"
29cdf0e10cSrcweir #include "SPreparedStatement.hxx"
30cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
32cdf0e10cSrcweir #include <com/sun/star/sdbc/TransactionIsolation.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir using namespace connectivity::skeleton;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //------------------------------------------------------------------------------
38cdf0e10cSrcweir using namespace com::sun::star::uno;
39cdf0e10cSrcweir using namespace com::sun::star::lang;
40cdf0e10cSrcweir using namespace com::sun::star::beans;
41cdf0e10cSrcweir using namespace com::sun::star::sdbc;
42cdf0e10cSrcweir // --------------------------------------------------------------------------------
OConnection(SkeletonDriver * _pDriver)43cdf0e10cSrcweir OConnection::OConnection(SkeletonDriver*    _pDriver)
44cdf0e10cSrcweir                          : OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this),
45cdf0e10cSrcweir                          OMetaConnection_BASE(m_aMutex),
46cdf0e10cSrcweir                          m_pDriver(_pDriver),
47cdf0e10cSrcweir                          m_bClosed(sal_False),
48cdf0e10cSrcweir                          m_xMetaData(NULL),
49cdf0e10cSrcweir                          m_bUseCatalog(sal_False),
50cdf0e10cSrcweir                          m_bUseOldDateFormat(sal_False)
51cdf0e10cSrcweir {
52cdf0e10cSrcweir     m_pDriver->acquire();
53cdf0e10cSrcweir }
54cdf0e10cSrcweir //-----------------------------------------------------------------------------
~OConnection()55cdf0e10cSrcweir OConnection::~OConnection()
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     if(!isClosed())
58cdf0e10cSrcweir         close();
59cdf0e10cSrcweir     m_pDriver->release();
60cdf0e10cSrcweir     m_pDriver = NULL;
61cdf0e10cSrcweir }
62cdf0e10cSrcweir //-----------------------------------------------------------------------------
release()63cdf0e10cSrcweir void SAL_CALL OConnection::release() throw()
64cdf0e10cSrcweir {
65cdf0e10cSrcweir     relase_ChildImpl();
66cdf0e10cSrcweir }
67cdf0e10cSrcweir // -----------------------------------------------------------------------------
68cdf0e10cSrcweir //-----------------------------------------------------------------------------
construct(const::rtl::OUString & url,const Sequence<PropertyValue> & info)69cdf0e10cSrcweir void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info)  throw(SQLException)
70cdf0e10cSrcweir {
71cdf0e10cSrcweir     osl_incrementInterlockedCount( &m_refCount );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     // some example code how to get the information out of the sequence
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     sal_Int32 nLen = url.indexOf(':');
76cdf0e10cSrcweir     nLen = url.indexOf(':',nLen+1);
77cdf0e10cSrcweir     ::rtl::OUString aDSN(RTL_CONSTASCII_USTRINGPARAM("DSN=")), aUID, aPWD, aSysDrvSettings;
78cdf0e10cSrcweir     aDSN += url.copy(nLen+1);
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     const char* pUser       = "user";
81cdf0e10cSrcweir     const char* pTimeout    = "Timeout";
82cdf0e10cSrcweir     const char* pSilent     = "Silent";
83cdf0e10cSrcweir     const char* pPwd        = "password";
84cdf0e10cSrcweir     const char* pUseCatalog = "UseCatalog";
85cdf0e10cSrcweir     const char* pSysDrv     = "SystemDriverSettings";
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     sal_Int32 nTimeout = 20;
88cdf0e10cSrcweir     sal_Bool bSilent = sal_True;
89cdf0e10cSrcweir     const PropertyValue *pBegin = info.getConstArray();
90cdf0e10cSrcweir     const PropertyValue *pEnd   = pBegin + info.getLength();
91cdf0e10cSrcweir     for(;pBegin != pEnd;++pBegin)
92cdf0e10cSrcweir     {
93cdf0e10cSrcweir         if(!pBegin->Name.compareToAscii(pTimeout))
94cdf0e10cSrcweir             pBegin->Value >>= nTimeout;
95cdf0e10cSrcweir         else if(!pBegin->Name.compareToAscii(pSilent))
96cdf0e10cSrcweir             pBegin->Value >>= bSilent;
97cdf0e10cSrcweir         else if(!pBegin->Name.compareToAscii(pUser))
98cdf0e10cSrcweir         {
99cdf0e10cSrcweir             pBegin->Value >>= aUID;
100cdf0e10cSrcweir             aDSN = aDSN + ::rtl::OUString::createFromAscii(";UID=") + aUID;
101cdf0e10cSrcweir         }
102cdf0e10cSrcweir         else if(!pBegin->Name.compareToAscii(pPwd))
103cdf0e10cSrcweir         {
104cdf0e10cSrcweir             pBegin->Value >>= aPWD;
105cdf0e10cSrcweir             aDSN = aDSN + ::rtl::OUString::createFromAscii(";PWD=") + aPWD;
106cdf0e10cSrcweir         }
107cdf0e10cSrcweir         else if(!pBegin->Name.compareToAscii(pUseCatalog))
108cdf0e10cSrcweir         {
109cdf0e10cSrcweir             pBegin->Value >>= m_bUseCatalog;
110cdf0e10cSrcweir         }
111cdf0e10cSrcweir         else if(!pBegin->Name.compareToAscii(pSysDrv))
112cdf0e10cSrcweir         {
113cdf0e10cSrcweir             pBegin->Value >>= aSysDrvSettings;
114cdf0e10cSrcweir             aDSN += ::rtl::OUString::createFromAscii(";");
115cdf0e10cSrcweir             aDSN += aSysDrvSettings;
116cdf0e10cSrcweir         }
117cdf0e10cSrcweir     }
118cdf0e10cSrcweir     m_sUser = aUID;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     osl_decrementInterlockedCount( &m_refCount );
121cdf0e10cSrcweir }
122cdf0e10cSrcweir // XServiceInfo
123cdf0e10cSrcweir // --------------------------------------------------------------------------------
124cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.skeleton.OConnection", "com.sun.star.sdbc.Connection")
125cdf0e10cSrcweir 
126cdf0e10cSrcweir // --------------------------------------------------------------------------------
createStatement()127cdf0e10cSrcweir Reference< XStatement > SAL_CALL OConnection::createStatement(  ) throw(SQLException, RuntimeException)
128cdf0e10cSrcweir {
129cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
130cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     // create a statement
133cdf0e10cSrcweir     // the statement can only be executed once
134cdf0e10cSrcweir     Reference< XStatement > xReturn = new OStatement(this);
135cdf0e10cSrcweir     m_aStatements.push_back(WeakReferenceHelper(xReturn));
136cdf0e10cSrcweir     return xReturn;
137cdf0e10cSrcweir }
138cdf0e10cSrcweir // --------------------------------------------------------------------------------
prepareStatement(const::rtl::OUString & _sSql)139cdf0e10cSrcweir Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
140cdf0e10cSrcweir {
141cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
142cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     // the pre
145cdf0e10cSrcweir     if(m_aTypeInfo.empty())
146cdf0e10cSrcweir         buildTypeInfo();
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     // create a statement
149cdf0e10cSrcweir     // the statement can only be executed more than once
150cdf0e10cSrcweir     Reference< XPreparedStatement > xReturn = new OPreparedStatement(this,m_aTypeInfo,_sSql);
151cdf0e10cSrcweir     m_aStatements.push_back(WeakReferenceHelper(xReturn));
152cdf0e10cSrcweir     return xReturn;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir // --------------------------------------------------------------------------------
prepareCall(const::rtl::OUString & _sSql)155cdf0e10cSrcweir Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
156cdf0e10cSrcweir {
157cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
158cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     // not implemented yet :-) a task to do
161cdf0e10cSrcweir     return NULL;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir // --------------------------------------------------------------------------------
nativeSQL(const::rtl::OUString & _sSql)164cdf0e10cSrcweir ::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
165cdf0e10cSrcweir {
166cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
167cdf0e10cSrcweir     // when you need to transform SQL92 to you driver specific you can do it here
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     return _sSql;
170cdf0e10cSrcweir }
171cdf0e10cSrcweir // --------------------------------------------------------------------------------
setAutoCommit(sal_Bool autoCommit)172cdf0e10cSrcweir void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
175cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
176cdf0e10cSrcweir     // here you  have to set your commit mode please have a look at the jdbc documentation to get a clear explanation
177cdf0e10cSrcweir }
178cdf0e10cSrcweir // --------------------------------------------------------------------------------
getAutoCommit()179cdf0e10cSrcweir sal_Bool SAL_CALL OConnection::getAutoCommit(  ) throw(SQLException, RuntimeException)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
182cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
183cdf0e10cSrcweir     // you have to distinguish which if you are in autocommit mode or not
184cdf0e10cSrcweir     // at normal case true should be fine here
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     return sal_True;
187cdf0e10cSrcweir }
188cdf0e10cSrcweir // --------------------------------------------------------------------------------
commit()189cdf0e10cSrcweir void SAL_CALL OConnection::commit(  ) throw(SQLException, RuntimeException)
190cdf0e10cSrcweir {
191cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
192cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     // when you database does support transactions you should commit here
195cdf0e10cSrcweir }
196cdf0e10cSrcweir // --------------------------------------------------------------------------------
rollback()197cdf0e10cSrcweir void SAL_CALL OConnection::rollback(  ) throw(SQLException, RuntimeException)
198cdf0e10cSrcweir {
199cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
200cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     // same as commit but for the other case
204cdf0e10cSrcweir }
205cdf0e10cSrcweir // --------------------------------------------------------------------------------
isClosed()206cdf0e10cSrcweir sal_Bool SAL_CALL OConnection::isClosed(  ) throw(SQLException, RuntimeException)
207cdf0e10cSrcweir {
208cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
209cdf0e10cSrcweir 
210*a893be29SPedro Giffuni     // just simple -> we are close when we are disposed that means someone called dispose(); (XComponent)
211cdf0e10cSrcweir     return OConnection_BASE::rBHelper.bDisposed;
212cdf0e10cSrcweir }
213cdf0e10cSrcweir // --------------------------------------------------------------------------------
getMetaData()214cdf0e10cSrcweir Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData(  ) throw(SQLException, RuntimeException)
215cdf0e10cSrcweir {
216cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
217cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     // here we have to create the class with biggest interface
220cdf0e10cSrcweir     // The answer is 42 :-)
221cdf0e10cSrcweir     Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
222cdf0e10cSrcweir     if(!xMetaData.is())
223cdf0e10cSrcweir     {
224cdf0e10cSrcweir         xMetaData = new ODatabaseMetaData(this); // need the connection because it can return it
225cdf0e10cSrcweir         m_xMetaData = xMetaData;
226cdf0e10cSrcweir     }
227cdf0e10cSrcweir 
228cdf0e10cSrcweir     return xMetaData;
229cdf0e10cSrcweir }
230cdf0e10cSrcweir // --------------------------------------------------------------------------------
setReadOnly(sal_Bool readOnly)231cdf0e10cSrcweir void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException)
232cdf0e10cSrcweir {
233cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
234cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     // set you connection to readonly
237cdf0e10cSrcweir }
238cdf0e10cSrcweir // --------------------------------------------------------------------------------
isReadOnly()239cdf0e10cSrcweir sal_Bool SAL_CALL OConnection::isReadOnly(  ) throw(SQLException, RuntimeException)
240cdf0e10cSrcweir {
241cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
242cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     // return if your connection to readonly
245cdf0e10cSrcweir     return sal_False;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir // --------------------------------------------------------------------------------
setCatalog(const::rtl::OUString & catalog)248cdf0e10cSrcweir void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)
249cdf0e10cSrcweir {
250cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
251cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
252cdf0e10cSrcweir 
253cdf0e10cSrcweir     // if your database doesn't work with catalogs you go to next method otherwise you kjnow what to do
254cdf0e10cSrcweir }
255cdf0e10cSrcweir // --------------------------------------------------------------------------------
getCatalog()256cdf0e10cSrcweir ::rtl::OUString SAL_CALL OConnection::getCatalog(  ) throw(SQLException, RuntimeException)
257cdf0e10cSrcweir {
258cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
259cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     // return your current catalog
263cdf0e10cSrcweir     return ::rtl::OUString();
264cdf0e10cSrcweir }
265cdf0e10cSrcweir // --------------------------------------------------------------------------------
setTransactionIsolation(sal_Int32 level)266cdf0e10cSrcweir void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException)
267cdf0e10cSrcweir {
268cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
269cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     // set your isolation level
272cdf0e10cSrcweir     // please have a look at @see com.sun.star.sdbc.TransactionIsolation
273cdf0e10cSrcweir }
274cdf0e10cSrcweir // --------------------------------------------------------------------------------
getTransactionIsolation()275cdf0e10cSrcweir sal_Int32 SAL_CALL OConnection::getTransactionIsolation(  ) throw(SQLException, RuntimeException)
276cdf0e10cSrcweir {
277cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
278cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     // please have a look at @see com.sun.star.sdbc.TransactionIsolation
282cdf0e10cSrcweir     return TransactionIsolation::NONE;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir // --------------------------------------------------------------------------------
getTypeMap()285cdf0e10cSrcweir Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap(  ) throw(SQLException, RuntimeException)
286cdf0e10cSrcweir {
287cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
288cdf0e10cSrcweir     checkDisposed(OConnection_BASE::rBHelper.bDisposed);
289cdf0e10cSrcweir 
290cdf0e10cSrcweir     // if your driver has special database types you can return it here
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     return NULL;
293cdf0e10cSrcweir }
294cdf0e10cSrcweir // --------------------------------------------------------------------------------
setTypeMap(const Reference<::com::sun::star::container::XNameAccess> & typeMap)295cdf0e10cSrcweir void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
296cdf0e10cSrcweir {
297cdf0e10cSrcweir     // the other way around
298cdf0e10cSrcweir }
299cdf0e10cSrcweir // --------------------------------------------------------------------------------
300cdf0e10cSrcweir // XCloseable
close()301cdf0e10cSrcweir void SAL_CALL OConnection::close(  ) throw(SQLException, RuntimeException)
302cdf0e10cSrcweir {
303cdf0e10cSrcweir     // we just dispose us
304cdf0e10cSrcweir     {
305cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
306cdf0e10cSrcweir         checkDisposed(OConnection_BASE::rBHelper.bDisposed);
307cdf0e10cSrcweir 
308cdf0e10cSrcweir     }
309cdf0e10cSrcweir     dispose();
310cdf0e10cSrcweir }
311cdf0e10cSrcweir // --------------------------------------------------------------------------------
312cdf0e10cSrcweir // XWarningsSupplier
getWarnings()313cdf0e10cSrcweir Any SAL_CALL OConnection::getWarnings(  ) throw(SQLException, RuntimeException)
314cdf0e10cSrcweir {
315cdf0e10cSrcweir     // when you collected some warnings -> return it
316cdf0e10cSrcweir     return Any();
317cdf0e10cSrcweir }
318cdf0e10cSrcweir // --------------------------------------------------------------------------------
clearWarnings()319cdf0e10cSrcweir void SAL_CALL OConnection::clearWarnings(  ) throw(SQLException, RuntimeException)
320cdf0e10cSrcweir {
321cdf0e10cSrcweir     // you should clear your collected warnings here
322cdf0e10cSrcweir }
323cdf0e10cSrcweir //--------------------------------------------------------------------
buildTypeInfo()324cdf0e10cSrcweir void OConnection::buildTypeInfo() throw( SQLException)
325cdf0e10cSrcweir {
326cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
327cdf0e10cSrcweir 
328cdf0e10cSrcweir     Reference< XResultSet> xRs = getMetaData ()->getTypeInfo ();
329cdf0e10cSrcweir     Reference< XRow> xRow(xRs,UNO_QUERY);
330cdf0e10cSrcweir     // Information for a single SQL type
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     // Loop on the result set until we reach end of file
333cdf0e10cSrcweir 
334cdf0e10cSrcweir     while (xRs->next ())
335cdf0e10cSrcweir     {
336cdf0e10cSrcweir         OTypeInfo aInfo;
337cdf0e10cSrcweir         aInfo.aTypeName         = xRow->getString   (1);
338cdf0e10cSrcweir         aInfo.nType             = xRow->getShort    (2);
339cdf0e10cSrcweir         aInfo.nPrecision        = xRow->getInt      (3);
340cdf0e10cSrcweir         aInfo.aLiteralPrefix    = xRow->getString   (4);
341cdf0e10cSrcweir         aInfo.aLiteralSuffix    = xRow->getString   (5);
342cdf0e10cSrcweir         aInfo.aCreateParams     = xRow->getString   (6);
343cdf0e10cSrcweir         aInfo.bNullable         = xRow->getBoolean  (7) == ColumnValue::NULLABLE;
344cdf0e10cSrcweir         aInfo.bCaseSensitive    = xRow->getBoolean  (8);
345cdf0e10cSrcweir         aInfo.nSearchType       = xRow->getShort    (9);
346cdf0e10cSrcweir         aInfo.bUnsigned         = xRow->getBoolean  (10);
347cdf0e10cSrcweir         aInfo.bCurrency         = xRow->getBoolean  (11);
348cdf0e10cSrcweir         aInfo.bAutoIncrement    = xRow->getBoolean  (12);
349cdf0e10cSrcweir         aInfo.aLocalTypeName    = xRow->getString   (13);
350cdf0e10cSrcweir         aInfo.nMinimumScale     = xRow->getShort    (14);
351cdf0e10cSrcweir         aInfo.nMaximumScale     = xRow->getShort    (15);
352cdf0e10cSrcweir         aInfo.nNumPrecRadix     = (sal_Int16)xRow->getInt(18);
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 
356cdf0e10cSrcweir         // Now that we have the type info, save it
357cdf0e10cSrcweir         // in the Hashtable if we don't already have an
358cdf0e10cSrcweir         // entry for this SQL type.
359cdf0e10cSrcweir 
360cdf0e10cSrcweir         m_aTypeInfo.push_back(aInfo);
361cdf0e10cSrcweir     }
362cdf0e10cSrcweir 
363cdf0e10cSrcweir     // Close the result set/statement.
364cdf0e10cSrcweir 
365cdf0e10cSrcweir     Reference< XCloseable> xClose(xRs,UNO_QUERY);
366cdf0e10cSrcweir     xClose->close();
367cdf0e10cSrcweir }
368cdf0e10cSrcweir //------------------------------------------------------------------------------
disposing()369cdf0e10cSrcweir void OConnection::disposing()
370cdf0e10cSrcweir {
371cdf0e10cSrcweir     // we noticed that we should be destroied in near future so we have to dispose our statements
372cdf0e10cSrcweir     ::osl::MutexGuard aGuard(m_aMutex);
373cdf0e10cSrcweir 
374cdf0e10cSrcweir     for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i)
375cdf0e10cSrcweir     {
376cdf0e10cSrcweir         Reference< XComponent > xComp(i->get(), UNO_QUERY);
377cdf0e10cSrcweir         if (xComp.is())
378cdf0e10cSrcweir             xComp->dispose();
379cdf0e10cSrcweir     }
380cdf0e10cSrcweir     m_aStatements.clear();
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     m_bClosed   = sal_True;
383cdf0e10cSrcweir     m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>();
384cdf0e10cSrcweir 
385cdf0e10cSrcweir     dispose_ChildImpl();
386cdf0e10cSrcweir     OConnection_BASE::disposing();
387cdf0e10cSrcweir }
388cdf0e10cSrcweir // -----------------------------------------------------------------------------
389