Kaydet (Commit) b2cefc2e authored tarafından Tamas Bunth's avatar Tamas Bunth Kaydeden (comit) Tamás Bunth

Revert removal of mysql jdbc connector

And also make some minor fixes so it cooperates with the new mysqlc
library.

Change-Id: I866add99a699150c6550ee7f7ff2ee947e07117c
Reviewed-on: https://gerrit.libreoffice.org/61648
Tested-by: Jenkins
Reviewed-by: 's avatarTamás Bunth <btomi96@gmail.com>
üst ba672343
......@@ -403,6 +403,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
msfilter \
$(call gb_Helper_optional,SCRIPTING,msforms) \
mtfrenderer \
$(call gb_Helper_optional,DBCONNECTIVITY,mysql_jdbc) \
$(call gb_Helper_optional,DBCONNECTIVITY,mysqlc) \
numbertext \
odbc \
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_Configuration_Configuration,driver_mysql_jdbc))
$(eval $(call gb_Configuration_add_spool_modules,driver_mysql_jdbc,connectivity/registry/mysql_jdbc,\
org/openoffice/Office/DataAccess/Drivers-mysql_jdbc.xcu \
))
$(eval $(call gb_Configuration_add_localized_datas,driver_mysql_jdbc,connectivity/registry/mysql_jdbc,\
org/openoffice/Office/DataAccess/Drivers.xcu \
))
# vim: set noet sw=4 ts=4:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_Library_Library,mysql_jdbc))
$(eval $(call gb_Library_set_componentfile,mysql_jdbc,connectivity/source/drivers/mysql_jdbc/mysql_jdbc))
$(eval $(call gb_Library_use_external,mysql_jdbc,boost_headers))
$(eval $(call gb_Library_use_sdk_api,mysql_jdbc))
$(eval $(call gb_Library_set_include,mysql_jdbc,\
$$(INCLUDE) \
-I$(SRCDIR)/connectivity/inc \
-I$(SRCDIR)/connectivity/source/inc \
))
$(eval $(call gb_Library_set_precompiled_header,mysql_jdbc,$(SRCDIR)/connectivity/inc/pch/precompiled_mysql))
$(eval $(call gb_Library_use_libraries,mysql_jdbc,\
cppu \
cppuhelper \
sal \
salhelper \
dbtools \
comphelper \
))
$(eval $(call gb_Library_add_exception_objects,mysql_jdbc,\
connectivity/source/drivers/mysql_jdbc/YDriver \
connectivity/source/drivers/mysql_jdbc/YTables \
connectivity/source/drivers/mysql_jdbc/YTable \
connectivity/source/drivers/mysql_jdbc/YViews \
connectivity/source/drivers/mysql_jdbc/YCatalog \
connectivity/source/drivers/mysql_jdbc/YColumns \
connectivity/source/drivers/mysql_jdbc/YUser \
connectivity/source/drivers/mysql_jdbc/YUsers \
connectivity/source/drivers/mysql_jdbc/Yservices \
))
# vim: set noet sw=4 ts=4:
......@@ -40,6 +40,8 @@ ifneq ($(ENABLE_JAVA),)
$(eval $(call gb_Module_add_targets,connectivity,\
Configuration_hsqldb \
Configuration_jdbc \
Configuration_mysql_jdbc \
Library_mysql_jdbc \
Jar_sdbc_hsqldb \
Library_hsqldb \
Library_jdbc \
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<node oor:name="Installed" install:module="mysql_jdbc">
<node oor:name="sdbc:mysql:jdbc:*" oor:op="replace">
<prop oor:name="Driver">
<value>org.openoffice.comp.drivers.MySQL.Driver</value>
</prop>
<prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
<value xml:lang="en-US">MySQL (JDBC)</value>
</prop>
<node oor:name="Properties">
<node oor:name="CharSet" oor:op="replace">
<prop oor:name="Value" oor:type="xs:string">
<value></value>
</prop>
</node>
<node oor:name="JavaDriverClass" oor:op="replace">
<prop oor:name="Value" oor:type="xs:string">
<value>com.mysql.jdbc.Driver</value>
</prop>
</node>
<node oor:name="AddIndexAppendix" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
<node oor:name="Features">
<node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="IgnoreDriverPrivileges" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="DisplayVersionColumns" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="UseDOSLineEnds" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="BooleanComparisonMode" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="FormsCheckRequiredFields" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
<node oor:name="MetaData">
<node oor:name="SupportsTableCreation" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="UseJava" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="Authentication" oor:op="replace">
<prop oor:name="Value" oor:type="xs:string">
<value>UserPassword</value>
</prop>
</node>
<node oor:name="SupportsColumnDescription" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
</node>
<node oor:name="sdbc:mysql:odbc:*" oor:op="replace">
<prop oor:name="Driver">
<value>org.openoffice.comp.drivers.MySQL.Driver</value>
</prop>
<prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
<value xml:lang="en-US">MySQL (ODBC)</value>
</prop>
<node oor:name="Properties">
<node oor:name="CharSet" oor:op="replace">
<prop oor:name="Value" oor:type="xs:string">
<value></value>
</prop>
</node>
<node oor:name="AddIndexAppendix" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
<node oor:name="Features">
<node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="IgnoreDriverPrivileges" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="DisplayVersionColumns" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="UseDOSLineEnds" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="BooleanComparisonMode" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="FormsCheckRequiredFields" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
<node oor:name="MetaData">
<node oor:name="SupportsTableCreation" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="SupportsBrowsing" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="Authentication" oor:op="replace">
<prop oor:name="Value" oor:type="xs:string">
<value>UserPassword</value>
</prop>
</node>
</node>
</node>
<node oor:name="sdbc:mysql:mysqlc:*" oor:op="replace">
<prop oor:name="Driver">
<value>org.openoffice.comp.drivers.MySQL.Driver</value>
</prop>
<prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
<value xml:lang="en-US">MySQL (Native)</value>
</prop>
<node oor:name="Properties">
<node oor:name="CharSet" oor:op="replace">
<prop oor:name="Value" oor:type="xs:string">
<value></value>
</prop>
</node>
<node oor:name="LocalSocket" oor:op="replace">
<prop oor:name="Value" oor:type="xs:string">
<value></value>
</prop>
</node>
<node oor:name="NamedPipe" oor:op="replace">
<prop oor:name="Value" oor:type="xs:string">
<value></value>
</prop>
</node>
<node oor:name="AddIndexAppendix" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
<node oor:name="Features">
<node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="IgnoreDriverPrivileges" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="DisplayVersionColumns" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="UseDOSLineEnds" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="BooleanComparisonMode" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="FormsCheckRequiredFields" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
<node oor:name="MetaData">
<node oor:name="SupportsTableCreation" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
<node oor:name="Authentication" oor:op="replace">
<prop oor:name="Value" oor:type="xs:string">
<value>UserPassword</value>
</prop>
</node>
<node oor:name="SupportsColumnDescription" oor:op="replace">
<prop oor:name="Value" oor:type="xs:boolean">
<value>true</value>
</prop>
</node>
</node>
</node>
</node>
</oor:component-data>
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <mysql/YCatalog.hxx>
#include <mysql/YUsers.hxx>
#include <mysql/YTables.hxx>
#include <mysql/YViews.hxx>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <comphelper/types.hxx>
using namespace connectivity;
using namespace connectivity::mysql;
using namespace connectivity::sdbcx;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
OMySQLCatalog::OMySQLCatalog(const Reference<XConnection>& _xConnection)
: OCatalog(_xConnection)
, m_xConnection(_xConnection)
{
}
void OMySQLCatalog::refreshObjects(const Sequence<OUString>& _sKindOfObject,
::std::vector<OUString>& _rNames)
{
Reference<XResultSet> xResult = m_xMetaData->getTables(Any(), "%", "%", _sKindOfObject);
fillNames(xResult, _rNames);
}
void OMySQLCatalog::refreshTables()
{
::std::vector<OUString> aVector;
Sequence<OUString> sTableTypes(3);
sTableTypes[0] = "VIEW";
sTableTypes[1] = "TABLE";
sTableTypes[2] = "%"; // just to be sure to include anything else ....
refreshObjects(sTableTypes, aVector);
if (m_pTables)
m_pTables->reFill(aVector);
else
m_pTables.reset(new OTables(m_xMetaData, *this, m_aMutex, aVector));
}
void OMySQLCatalog::refreshViews()
{
Sequence<OUString> aTypes{ "VIEW" };
// let's simply assume the server is new enough to support views. Current drivers
// as of this writing might not return the proper information in getTableTypes, so
// don't rely on it.
::std::vector<OUString> aVector;
refreshObjects(aTypes, aVector);
if (m_pViews)
m_pViews->reFill(aVector);
else
m_pViews.reset(new OViews(m_xMetaData, *this, m_aMutex, aVector));
}
void OMySQLCatalog::refreshGroups() {}
void OMySQLCatalog::refreshUsers()
{
::std::vector<OUString> aVector;
Reference<XStatement> xStmt = m_xConnection->createStatement();
Reference<XResultSet> xResult = xStmt->executeQuery(
"SELECT grantee FROM information_schema.user_privileges GROUP BY grantee");
if (xResult.is())
{
Reference<XRow> xRow(xResult, UNO_QUERY);
while (xResult->next())
aVector.push_back(xRow->getString(1));
::comphelper::disposeComponent(xResult);
}
::comphelper::disposeComponent(xStmt);
if (m_pUsers)
m_pUsers->reFill(aVector);
else
m_pUsers.reset(new OUsers(*this, m_aMutex, aVector, m_xConnection, this));
}
Any SAL_CALL OMySQLCatalog::queryInterface(const Type& rType)
{
if (rType == cppu::UnoType<XGroupsSupplier>::get())
return Any();
return OCatalog::queryInterface(rType);
}
Sequence<Type> SAL_CALL OMySQLCatalog::getTypes()
{
Sequence<Type> aTypes = OCatalog::getTypes();
std::vector<Type> aOwnTypes;
aOwnTypes.reserve(aTypes.getLength());
const Type* pBegin = aTypes.getConstArray();
const Type* pEnd = pBegin + aTypes.getLength();
for (; pBegin != pEnd; ++pBegin)
{
if (!(*pBegin == cppu::UnoType<XGroupsSupplier>::get()))
{
aOwnTypes.push_back(*pBegin);
}
}
return Sequence<Type>(aOwnTypes.data(), aOwnTypes.size());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <mysql/YColumns.hxx>
#include <TConnection.hxx>
using namespace ::comphelper;
using namespace connectivity::mysql;
using namespace connectivity::sdbcx;
using namespace connectivity;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
OMySQLColumns::OMySQLColumns(::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
const ::std::vector<OUString>& _rVector)
: OColumnsHelper(_rParent, true /*_bCase*/, _rMutex, _rVector, true /*_bUseHardRef*/)
{
}
Reference<XPropertySet> OMySQLColumns::createDescriptor() { return new OMySQLColumn; }
OMySQLColumn::OMySQLColumn()
: connectivity::sdbcx::OColumn(true)
{
construct();
}
void OMySQLColumn::construct()
{
m_sAutoIncrement = "auto_increment";
registerProperty(
OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_AUTOINCREMENTCREATION),
PROPERTY_ID_AUTOINCREMENTCREATION, 0, &m_sAutoIncrement,
cppu::UnoType<decltype(m_sAutoIncrement)>::get());
}
::cppu::IPropertyArrayHelper* OMySQLColumn::createArrayHelper(sal_Int32 /*_nId*/) const
{
return doCreateArrayHelper();
}
::cppu::IPropertyArrayHelper& SAL_CALL OMySQLColumn::getInfoHelper()
{
return *OMySQLColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
}
Sequence<OUString> SAL_CALL OMySQLColumn::getSupportedServiceNames()
{
Sequence<OUString> aSupported{ "com.sun.star.sdbcx.Column" };
return aSupported;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <mysql/YTables.hxx>
#include <mysql/YViews.hxx>
#include <mysql/YTable.hxx>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbcx/Privilege.hpp>
#include <com/sun/star/sdbc/KeyRule.hpp>
#include <com/sun/star/sdbcx/KeyType.hpp>
#include <mysql/YCatalog.hxx>
#include <connectivity/dbtools.hxx>
#include <connectivity/dbexception.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <comphelper/types.hxx>
#include <TConnection.hxx>
using namespace ::comphelper;
using namespace connectivity;
using namespace ::cppu;
using namespace connectivity::mysql;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
using namespace dbtools;
sdbcx::ObjectType OTables::createObject(const OUString& _rName)
{
OUString sCatalog, sSchema, sTable;
::dbtools::qualifiedNameComponents(m_xMetaData, _rName, sCatalog, sSchema, sTable,
::dbtools::EComposeRule::InDataManipulation);
Sequence<OUString> sTableTypes(3);
sTableTypes[0] = "VIEW";
sTableTypes[1] = "TABLE";
sTableTypes[2] = "%"; // just to be sure to include anything else ....
Any aCatalog;
if (!sCatalog.isEmpty())
aCatalog <<= sCatalog;
Reference<XResultSet> xResult = m_xMetaData->getTables(aCatalog, sSchema, sTable, sTableTypes);
sdbcx::ObjectType xRet = nullptr;
if (xResult.is())
{
Reference<XRow> xRow(xResult, UNO_QUERY);
if (xResult->next()) // there can be only one table with this name
{
sal_Int32 const nPrivileges = Privilege::DROP | Privilege::REFERENCE | Privilege::ALTER
| Privilege::CREATE | Privilege::READ | Privilege::DELETE
| Privilege::UPDATE | Privilege::INSERT
| Privilege::SELECT;
OMySQLTable* pRet = new OMySQLTable(
this, static_cast<OMySQLCatalog&>(m_rParent).getConnection(), sTable,
xRow->getString(4), xRow->getString(5), sSchema, sCatalog, nPrivileges);
xRet = pRet;
}
::comphelper::disposeComponent(xResult);
}
return xRet;
}
void OTables::impl_refresh() { static_cast<OMySQLCatalog&>(m_rParent).refreshTables(); }
void OTables::disposing()
{
m_xMetaData.clear();
OCollection::disposing();
}
Reference<XPropertySet> OTables::createDescriptor()
{
return new OMySQLTable(this, static_cast<OMySQLCatalog&>(m_rParent).getConnection());
}
// XAppend
sdbcx::ObjectType OTables::appendObject(const OUString& _rForName,
const Reference<XPropertySet>& descriptor)
{
createTable(descriptor);
return createObject(_rForName);
}
// XDrop
void OTables::dropObject(sal_Int32 _nPos, const OUString& _sElementName)
{
Reference<XInterface> xObject(getObject(_nPos));
bool bIsNew = connectivity::sdbcx::ODescriptor::isNew(xObject);
if (!bIsNew)
{
Reference<XConnection> xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
OUString sCatalog, sSchema, sTable;
::dbtools::qualifiedNameComponents(m_xMetaData, _sElementName, sCatalog, sSchema, sTable,
::dbtools::EComposeRule::InDataManipulation);
OUString aSql("DROP ");
Reference<XPropertySet> xProp(xObject, UNO_QUERY);
bool bIsView = xProp.is()
&& ::comphelper::getString(xProp->getPropertyValue(
OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
== "VIEW";
if (bIsView) // here we have a view
aSql += "VIEW ";
else
aSql += "TABLE ";
OUString sComposedName(
::dbtools::composeTableName(m_xMetaData, sCatalog, sSchema, sTable, true,
::dbtools::EComposeRule::InDataManipulation));
aSql += sComposedName;
Reference<XStatement> xStmt = xConnection->createStatement();
if (xStmt.is())
{
xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
}
// if no exception was thrown we must delete it from the views
if (bIsView)
{
OViews* pViews
= static_cast<OViews*>(static_cast<OMySQLCatalog&>(m_rParent).getPrivateViews());
if (pViews && pViews->hasByName(_sElementName))
pViews->dropByNameImpl(_sElementName);
}
}
}
OUString OTables::adjustSQL(const OUString& _sSql)
{
OUString sSQL = _sSql;
static const char s_sUNSIGNED[] = "UNSIGNED";
sal_Int32 nIndex = sSQL.indexOf(s_sUNSIGNED);
while (nIndex != -1)
{
sal_Int32 nParen = sSQL.indexOf(')', nIndex);
sal_Int32 nPos = nIndex + strlen(s_sUNSIGNED);
OUString sNewUnsigned(sSQL.copy(nPos, nParen - nPos + 1));
sSQL = sSQL.replaceAt(nIndex, strlen(s_sUNSIGNED) + sNewUnsigned.getLength(),
sNewUnsigned + s_sUNSIGNED);
nIndex = sSQL.indexOf(s_sUNSIGNED, nIndex + strlen(s_sUNSIGNED) + sNewUnsigned.getLength());
}
return sSQL;
}
void OTables::createTable(const Reference<XPropertySet>& descriptor)
{
const Reference<XConnection> xConnection
= static_cast<OMySQLCatalog&>(m_rParent).getConnection();
const OUString aSql
= adjustSQL(::dbtools::createSqlCreateTableStatement(descriptor, xConnection));
Reference<XStatement> xStmt = xConnection->createStatement();
if (xStmt.is())
{
xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
}
}
void OTables::appendNew(const OUString& _rsNewTable)
{
insertElement(_rsNewTable, nullptr);
// notify our container listeners
ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rsNewTable), Any(), Any());
OInterfaceIteratorHelper2 aListenerLoop(m_aContainerListeners);
while (aListenerLoop.hasMoreElements())
static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent);
}
OUString OTables::getNameForObject(const sdbcx::ObjectType& _xObject)
{
OSL_ENSURE(_xObject.is(), "OTables::getNameForObject: Object is NULL!");
return ::dbtools::composeTableName(m_xMetaData, _xObject,
::dbtools::EComposeRule::InDataManipulation, false);
}
void OTables::addComment(const Reference<XPropertySet>& descriptor, OUStringBuffer& _rOut)
{
OUString sDesc;
descriptor->getPropertyValue(
OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION))
>>= sDesc;
if (!sDesc.isEmpty())
{
_rOut.append(" COMMENT '");
_rOut.append(sDesc);
_rOut.append("'");
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <mysql/YUsers.hxx>
#include <mysql/YUser.hxx>
#include <mysql/YTable.hxx>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <connectivity/sdbcx/IRefreshable.hxx>
#include <comphelper/types.hxx>
#include <connectivity/dbexception.hxx>
#include <connectivity/dbtools.hxx>
#include <TConnection.hxx>
using namespace ::comphelper;
using namespace connectivity;
using namespace connectivity::mysql;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
OUsers::OUsers(::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
const ::std::vector<OUString>& _rVector,
const css::uno::Reference<css::sdbc::XConnection>& _xConnection,
connectivity::sdbcx::IRefreshableUsers* _pParent)
: sdbcx::OCollection(_rParent, true, _rMutex, _rVector)
, m_xConnection(_xConnection)
, m_pParent(_pParent)
{
}
sdbcx::ObjectType OUsers::createObject(const OUString& _rName)
{
return new OMySQLUser(m_xConnection, _rName);
}
void OUsers::impl_refresh() { m_pParent->refreshUsers(); }
Reference<XPropertySet> OUsers::createDescriptor()
{
OUserExtend* pNew = new OUserExtend(m_xConnection);
return pNew;
}
// XAppend
sdbcx::ObjectType OUsers::appendObject(const OUString& _rForName,
const Reference<XPropertySet>& descriptor)
{
OUString aSql("GRANT USAGE ON * TO ");
OUString aQuote = m_xConnection->getMetaData()->getIdentifierQuoteString();
aSql += ::dbtools::quoteName(aQuote, _rForName) + " @\"%\" ";
OUString sPassword;
descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD))
>>= sPassword;
if (!sPassword.isEmpty())
{
aSql += " IDENTIFIED BY '";
aSql += sPassword;
aSql += "'";
}
Reference<XStatement> xStmt = m_xConnection->createStatement();
if (xStmt.is())
xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
return createObject(_rForName);
}
// XDrop
void OUsers::dropObject(sal_Int32 /*_nPos*/, const OUString& _sElementName)
{
OUString aSql("DROP USER ");
OUString aQuote = m_xConnection->getMetaData()->getIdentifierQuoteString();
aSql += ::dbtools::quoteName(aQuote, _sElementName);
Reference<XStatement> xStmt = m_xConnection->createStatement();
if (xStmt.is())
xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <mysql/YViews.hxx>
#include <mysql/YTables.hxx>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/KeyRule.hpp>
#include <com/sun/star/sdbcx/KeyType.hpp>
#include <com/sun/star/sdbcx/CheckOption.hpp>
#include <mysql/YCatalog.hxx>
#include <connectivity/dbtools.hxx>
#include <connectivity/dbexception.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <connectivity/sdbcx/VView.hxx>
#include <comphelper/types.hxx>
#include <TConnection.hxx>
using namespace ::comphelper;
using namespace ::cppu;
using namespace connectivity;
using namespace connectivity::mysql;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
using namespace dbtools;
typedef connectivity::sdbcx::OCollection OCollection_TYPE;
sdbcx::ObjectType OViews::createObject(const OUString& _rName)
{
OUString sCatalog, sSchema, sTable;
::dbtools::qualifiedNameComponents(m_xMetaData, _rName, sCatalog, sSchema, sTable,
::dbtools::EComposeRule::InDataManipulation);
return new ::connectivity::sdbcx::OView(isCaseSensitive(), sTable, m_xMetaData, OUString(),
sSchema, sCatalog);
}
void OViews::impl_refresh() { static_cast<OMySQLCatalog&>(m_rParent).refreshTables(); }
void OViews::disposing()
{
m_xMetaData.clear();
OCollection::disposing();
}
Reference<XPropertySet> OViews::createDescriptor()
{
Reference<XConnection> xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
connectivity::sdbcx::OView* pNew
= new connectivity::sdbcx::OView(true, xConnection->getMetaData());
return pNew;
}
// XAppend
sdbcx::ObjectType OViews::appendObject(const OUString& _rForName,
const Reference<XPropertySet>& descriptor)
{
createView(descriptor);
return createObject(_rForName);
}
// XDrop
void OViews::dropObject(sal_Int32 _nPos, const OUString& /*_sElementName*/)
{
if (m_bInDrop)
return;
Reference<XInterface> xObject(getObject(_nPos));
bool bIsNew = connectivity::sdbcx::ODescriptor::isNew(xObject);
if (!bIsNew)
{
OUString aSql("DROP VIEW");
Reference<XPropertySet> xProp(xObject, UNO_QUERY);
aSql += ::dbtools::composeTableName(m_xMetaData, xProp,
::dbtools::EComposeRule::InTableDefinitions, true);
Reference<XConnection> xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
Reference<XStatement> xStmt = xConnection->createStatement();
xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
}
}
void OViews::dropByNameImpl(const OUString& elementName)
{
m_bInDrop = true;
OCollection_TYPE::dropByName(elementName);
m_bInDrop = false;
}
void OViews::createView(const Reference<XPropertySet>& descriptor)
{
Reference<XConnection> xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
OUString aSql("CREATE VIEW ");
OUString sCommand;
aSql += ::dbtools::composeTableName(m_xMetaData, descriptor,
::dbtools::EComposeRule::InTableDefinitions, true);
aSql += " AS ";
descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND))
>>= sCommand;
aSql += sCommand;
Reference<XStatement> xStmt = xConnection->createStatement();
if (xStmt.is())
{
xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
}
// insert the new view also in the tables collection
OTables* pTables
= static_cast<OTables*>(static_cast<OMySQLCatalog&>(m_rParent).getPrivateTables());
if (pTables)
{
OUString sName = ::dbtools::composeTableName(
m_xMetaData, descriptor, ::dbtools::EComposeRule::InDataManipulation, false);
pTables->appendNew(sName);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <mysql/YDriver.hxx>
#include <cppuhelper/factory.hxx>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
using namespace connectivity::mysql;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::lang::XSingleServiceFactory;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
typedef Reference<XSingleServiceFactory> (*createFactoryFunc)(
const Reference<XMultiServiceFactory>& rServiceManager, const OUString& rComponentName,
::cppu::ComponentInstantiation pCreateFunction, const Sequence<OUString>& rServiceNames,
rtl_ModuleCount*);
extern "C" SAL_DLLPUBLIC_EXPORT void*
mysql_jdbc_component_getFactory(const sal_Char* pImplementationName, void* pServiceManager,
void* /*pRegistryKey*/)
{
if (!pServiceManager)
{
return nullptr;
}
Reference<XSingleServiceFactory> xRet;
const Reference<XMultiServiceFactory> xServiceManager(
static_cast<XMultiServiceFactory*>(pServiceManager));
const OUString sImplementationName(OUString::createFromAscii(pImplementationName));
if (ODriverDelegator::getImplementationName_Static() == sImplementationName)
try
{
xRet = ::cppu::createSingleFactory(xServiceManager, sImplementationName,
ODriverDelegator_CreateInstance,
ODriverDelegator::getSupportedServiceNames_Static());
}
catch (...)
{
}
if (xRet.is())
xRet->acquire();
return xRet.get();
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="mysql_jdbc" xmlns="http://openoffice.org/2010/uno-components">
<implementation name="org.openoffice.comp.drivers.MySQL.Driver">
<service name="com.sun.star.sdbc.Driver"/>
<service name="com.sun.star.sdbcx.Driver"/>
</implementation>
</component>
......@@ -126,6 +126,10 @@ namespace dbaui
const OUString sURLPrefix = aTypeLoop.getURLPrefix();
if ( !sURLPrefix.isEmpty() )
{
// skip mysql connection variations. It is handled in another window.
if(sURLPrefix.startsWith("sdbc:mysql:") && !sURLPrefix.startsWith("sdbc:mysql:jdbc:"))
continue;
OUString sDisplayName = aTypeLoop.getDisplayName();
if ( m_pDatasourceType->GetEntryPos( sDisplayName ) == LISTBOX_ENTRY_NOTFOUND
&& approveDatasourceType( sURLPrefix, sDisplayName ) )
......
......@@ -85,6 +85,11 @@ namespace dbaui
virtual void fillWindows(std::vector< std::unique_ptr<ISaveValueWrapper> >& _rControlList) override;
void onTypeSelected(const OUString& _sURLPrefix);
/**
* Initializes the listbox, which contains entires each representing a
* connection to an existing database.
*/
void initializeTypeList();
void implSetCurrentType( const OUString& _eType );
......
......@@ -331,8 +331,9 @@ endif
ifeq ($(ENABLE_JAVA),TRUE)
postprocess_FILES_main += \
$(call gb_XcuModuleTarget_get_target,connectivity/registry/hsqldb)/org/openoffice/Office/DataAccess/Drivers-hsqldb.xcu \
$(call gb_XcuModuleTarget_get_target,connectivity/registry/jdbc)/org/openoffice/Office/DataAccess/Drivers-jdbc.xcu
postprocess_DRIVERS += hsqldb jdbc
$(call gb_XcuModuleTarget_get_target,connectivity/registry/jdbc)/org/openoffice/Office/DataAccess/Drivers-jdbc.xcu \
$(call gb_XcuModuleTarget_get_target,connectivity/registry/mysql_jdbc)/org/openoffice/Office/DataAccess/Drivers-mysql_jdbc.xcu
postprocess_DRIVERS += hsqldb jdbc mysql_jdbc
endif
ifeq ($(ENABLE_FIREBIRD_SDBC),TRUE)
postprocess_FILES_main += \
......
......@@ -261,6 +261,7 @@ $(eval $(call gb_Rdb_add_components,services,\
$(if $(ENABLE_JAVA), \
connectivity/source/drivers/hsqldb/hsqldb \
connectivity/source/drivers/jdbc/jdbc \
connectivity/source/drivers/mysql_jdbc/mysql_jdbc \
) \
connectivity/source/manager/sdbc2 \
connectivity/source/drivers/writer/writer \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment