1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "dbase/DConnection.hxx"
31 #include "dbase/DDatabaseMetaData.hxx"
32 #include "dbase/DCatalog.hxx"
33 #include "dbase/DDriver.hxx"
34 #include <com/sun/star/lang/DisposedException.hpp>
35 #include "dbase/DPreparedStatement.hxx"
36 #include "dbase/DStatement.hxx"
37 #include <tools/debug.hxx>
38 #include <connectivity/dbexception.hxx>
40 using namespace connectivity::dbase
;
41 using namespace connectivity::file
;
43 typedef connectivity::file::OConnection OConnection_BASE
;
45 //------------------------------------------------------------------------------
46 using namespace ::com::sun::star::uno
;
47 using namespace ::com::sun::star::beans
;
48 using namespace ::com::sun::star::sdbcx
;
49 using namespace ::com::sun::star::sdbc
;
50 using namespace ::com::sun::star::lang
;
52 DBG_NAME(ODbaseConnection
)
53 // --------------------------------------------------------------------------------
54 ODbaseConnection::ODbaseConnection(ODriver
* _pDriver
) : OConnection(_pDriver
)
56 DBG_CTOR(ODbaseConnection
,NULL
);
57 m_aFilenameExtension
= String::CreateFromAscii("dbf");
59 //-----------------------------------------------------------------------------
60 ODbaseConnection::~ODbaseConnection()
62 DBG_DTOR(ODbaseConnection
,NULL
);
66 // --------------------------------------------------------------------------------
67 IMPLEMENT_SERVICE_INFO(ODbaseConnection
, "com.sun.star.sdbc.drivers.dbase.Connection", "com.sun.star.sdbc.Connection")
69 // --------------------------------------------------------------------------------
70 Reference
< XDatabaseMetaData
> SAL_CALL
ODbaseConnection::getMetaData( ) throw(SQLException
, RuntimeException
)
72 ::osl::MutexGuard
aGuard( m_aMutex
);
73 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
76 Reference
< XDatabaseMetaData
> xMetaData
= m_xMetaData
;
79 xMetaData
= new ODbaseDatabaseMetaData(this);
80 m_xMetaData
= xMetaData
;
85 //------------------------------------------------------------------------------
86 ::com::sun::star::uno::Reference
< XTablesSupplier
> ODbaseConnection::createCatalog()
88 ::osl::MutexGuard
aGuard( m_aMutex
);
89 Reference
< XTablesSupplier
> xTab
= m_xCatalog
;
92 ODbaseCatalog
*pCat
= new ODbaseCatalog(this);
98 // --------------------------------------------------------------------------------
99 Reference
< XStatement
> SAL_CALL
ODbaseConnection::createStatement( ) throw(SQLException
, RuntimeException
)
101 ::osl::MutexGuard
aGuard( m_aMutex
);
102 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
105 Reference
< XStatement
> xReturn
= new ODbaseStatement(this);
106 m_aStatements
.push_back(WeakReferenceHelper(xReturn
));
109 // --------------------------------------------------------------------------------
110 Reference
< XPreparedStatement
> SAL_CALL
ODbaseConnection::prepareStatement( const ::rtl::OUString
& sql
) throw(SQLException
, RuntimeException
)
112 ::osl::MutexGuard
aGuard( m_aMutex
);
113 checkDisposed(OConnection_BASE::rBHelper
.bDisposed
);
116 ODbasePreparedStatement
* pStmt
= new ODbasePreparedStatement(this);
117 Reference
< XPreparedStatement
> xHoldAlive
= pStmt
;
118 pStmt
->construct(sql
);
119 m_aStatements
.push_back(WeakReferenceHelper(*pStmt
));
122 // --------------------------------------------------------------------------------
123 Reference
< XPreparedStatement
> SAL_CALL
ODbaseConnection::prepareCall( const ::rtl::OUString
& /*sql*/ ) throw(SQLException
, RuntimeException
)
125 ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
128 // -----------------------------------------------------------------------------
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */