1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <connectivity/sqlparse.hxx>
21 #include <connectivity/sqliterator.hxx>
22 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
23 #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
24 #include <com/sun/star/sdbc/XResultSet.hpp>
25 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
26 #include <com/sun/star/sdbc/XRow.hpp>
27 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/beans/PropertyState.hpp>
30 #include <com/sun/star/beans/PropertyValue.hpp>
31 #include <cppuhelper/servicefactory.hxx>
32 #include <com/sun/star/sdbc/XConnection.hpp>
33 #include <com/sun/star/sdbc/XDriver.hpp>
34 #include <connectivity/sqlnode.hxx>
36 using namespace connectivity
;
37 using namespace com::sun::star::sdbc
;
38 using namespace com::sun::star
;
39 using namespace com::sun::star::uno
;
40 using namespace com::sun::star::beans
;
44 void main( int argc
, char * argv
[] )
46 css::uno::Reference
< css::sdbc::XConnection
> m_xConnection
;
47 css::uno::Reference
< css::sdbc::XDriver
> m_xDriver
;
50 Reference
< css::lang::XMultiServiceFactory
> xFac
=
51 createRegistryServiceFactory(OUString("g:\\office50\\program\\applicat.rdb"),OUString());
55 m_xDriver
.set(xFac
->createInstance("com.sun.star.sdbc.driver.dbase.Driver"),UNO_QUERY
);
59 Sequence
<PropertyValue
> aValue
;
60 // aValue.getArray()[0] = PropertyValue( OUString("user"),0,makeAny(OUString("TEST1")),PropertyState_DIRECT_VALUE);
61 // aValue.getArray()[1] = PropertyValue( OUString("password"),0,makeAny(OUString("TEST1")),PropertyState_DIRECT_VALUE);
63 m_xConnection
= m_xDriver
->connect(OUString("sdbc:dbase:g:\\"),aValue
);
64 if(m_xConnection
.is())
66 Reference
<XStatement
> xStmt
= m_xConnection
->createStatement();
69 Reference
<XResultSet
> xRes
= xStmt
->executeQuery(OUString("SELECT * FROM Tele"));
72 OUString
aPat( "%s\t" );
73 Reference
<XRow
> xRow(xRes
,UNO_QUERY
);
74 Reference
<XResultSetMetaData
> xMeta
= Reference
<XResultSetMetaDataSupplier
>(xRes
,UNO_QUERY
)->getMetaData();
75 for(sal_Int32 i
=1;i
<xMeta
->getColumnCount();++i
)
77 wprintf(aPat
.getStr(), xMeta
->getColumnName(i
).getStr());
79 printf("----------------------------------------------------------------------\n");
82 for(sal_Int32 j
=1;j
<xMeta
->getColumnCount();++j
)
83 wprintf(aPat
.getStr(), xRow
->getString(j
).getStr());
94 printf("Exception thrown!\n");
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */