1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_dbaccess.hxx" 30 #ifndef _DBA_COREAPI_CALLABLESTATEMENT_HXX_ 31 #include <callablestatement.hxx> 32 #endif 33 #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_ 34 #include <com/sun/star/lang/DisposedException.hpp> 35 #endif 36 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ 37 #include <cppuhelper/typeprovider.hxx> 38 #endif 39 #ifndef _COMPHELPER_PROPERTY_HXX_ 40 #include <comphelper/property.hxx> 41 #endif 42 #ifndef _TOOLS_DEBUG_HXX //autogen 43 #include <tools/debug.hxx> 44 #endif 45 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC 46 #include "dbastrings.hrc" 47 #endif 48 #include <rtl/logfile.hxx> 49 50 using namespace dbaccess; 51 using namespace ::com::sun::star::sdbc; 52 using namespace ::com::sun::star::sdbcx; 53 using namespace ::com::sun::star::beans; 54 using namespace ::com::sun::star::uno; 55 using namespace ::com::sun::star::lang; 56 using namespace ::cppu; 57 using namespace ::osl; 58 59 // com::sun::star::lang::XTypeProvider 60 //-------------------------------------------------------------------------- 61 Sequence< Type > OCallableStatement::getTypes() throw (RuntimeException) 62 { 63 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTypes" ); 64 OTypeCollection aTypes(::getCppuType( (const Reference< XRow > *)0 ), 65 ::getCppuType( (const Reference< XOutParameters > *)0 ), 66 OPreparedStatement::getTypes() ); 67 68 return aTypes.getTypes(); 69 } 70 71 //-------------------------------------------------------------------------- 72 Sequence< sal_Int8 > OCallableStatement::getImplementationId() throw (RuntimeException) 73 { 74 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getImplementationId" ); 75 static OImplementationId * pId = 0; 76 if (! pId) 77 { 78 MutexGuard aGuard( Mutex::getGlobalMutex() ); 79 if (! pId) 80 { 81 static OImplementationId aId; 82 pId = &aId; 83 } 84 } 85 return pId->getImplementationId(); 86 } 87 88 // com::sun::star::uno::XInterface 89 //-------------------------------------------------------------------------- 90 Any OCallableStatement::queryInterface( const Type & rType ) throw (RuntimeException) 91 { 92 //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::queryInterface" ); 93 Any aIface = OPreparedStatement::queryInterface( rType ); 94 if (!aIface.hasValue()) 95 aIface = ::cppu::queryInterface( 96 rType, 97 static_cast< XRow * >( this ), 98 static_cast< XOutParameters * >( this )); 99 return aIface; 100 } 101 102 //-------------------------------------------------------------------------- 103 void OCallableStatement::acquire() throw () 104 { 105 OPreparedStatement::acquire(); 106 } 107 108 //-------------------------------------------------------------------------- 109 void OCallableStatement::release() throw () 110 { 111 OPreparedStatement::release(); 112 } 113 114 // XServiceInfo 115 //------------------------------------------------------------------------------ 116 rtl::OUString OCallableStatement::getImplementationName( ) throw(RuntimeException) 117 { 118 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getImplementationName" ); 119 return rtl::OUString::createFromAscii("com.sun.star.sdb.OCallableStatement"); 120 } 121 122 //------------------------------------------------------------------------------ 123 Sequence< ::rtl::OUString > OCallableStatement::getSupportedServiceNames( ) throw (RuntimeException) 124 { 125 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getSupportedServiceNames" ); 126 Sequence< ::rtl::OUString > aSNS( 2 ); 127 aSNS.getArray()[0] = SERVICE_SDBC_CALLABLESTATEMENT; 128 aSNS.getArray()[1] = SERVICE_SDB_CALLABLESTATEMENT; 129 return aSNS; 130 } 131 132 // XOutParameters 133 //------------------------------------------------------------------------------ 134 void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(SQLException, RuntimeException) 135 { 136 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::registerOutParameter" ); 137 MutexGuard aGuard(m_aMutex); 138 139 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 140 141 142 Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY)->registerOutParameter( parameterIndex, sqlType, typeName ); 143 } 144 145 //------------------------------------------------------------------------------ 146 void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException) 147 { 148 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::registerNumericOutParameter" ); 149 MutexGuard aGuard(m_aMutex); 150 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 151 152 Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY)->registerNumericOutParameter( parameterIndex, sqlType, scale ); 153 } 154 155 // XRow 156 //------------------------------------------------------------------------------ 157 sal_Bool SAL_CALL OCallableStatement::wasNull( ) throw(SQLException, RuntimeException) 158 { 159 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::wasNull" ); 160 MutexGuard aGuard(m_aMutex); 161 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 162 163 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->wasNull(); 164 } 165 166 //------------------------------------------------------------------------------ 167 ::rtl::OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 168 { 169 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getString" ); 170 MutexGuard aGuard(m_aMutex); 171 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 172 173 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getString( columnIndex ); 174 } 175 176 //------------------------------------------------------------------------------ 177 sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 178 { 179 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBoolean" ); 180 MutexGuard aGuard(m_aMutex); 181 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 182 183 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBoolean( columnIndex ); 184 } 185 186 //------------------------------------------------------------------------------ 187 sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 188 { 189 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getByte" ); 190 MutexGuard aGuard(m_aMutex); 191 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 192 193 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getByte( columnIndex ); 194 } 195 196 //------------------------------------------------------------------------------ 197 sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 198 { 199 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getShort" ); 200 MutexGuard aGuard(m_aMutex); 201 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 202 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getShort( columnIndex ); 203 } 204 205 //------------------------------------------------------------------------------ 206 sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 207 { 208 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getInt" ); 209 MutexGuard aGuard(m_aMutex); 210 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 211 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getInt( columnIndex ); 212 } 213 214 //------------------------------------------------------------------------------ 215 sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 216 { 217 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getLong" ); 218 MutexGuard aGuard(m_aMutex); 219 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 220 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getLong( columnIndex ); 221 } 222 223 //------------------------------------------------------------------------------ 224 float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 225 { 226 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getFloat" ); 227 MutexGuard aGuard(m_aMutex); 228 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 229 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getFloat( columnIndex ); 230 } 231 232 //------------------------------------------------------------------------------ 233 double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 234 { 235 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getDouble" ); 236 MutexGuard aGuard(m_aMutex); 237 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 238 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getDouble( columnIndex ); 239 } 240 241 //------------------------------------------------------------------------------ 242 Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 243 { 244 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBytes" ); 245 MutexGuard aGuard(m_aMutex); 246 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 247 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBytes( columnIndex ); 248 } 249 250 //------------------------------------------------------------------------------ 251 ::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 252 { 253 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getDate" ); 254 MutexGuard aGuard(m_aMutex); 255 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 256 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getDate( columnIndex ); 257 } 258 259 //------------------------------------------------------------------------------ 260 ::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 261 { 262 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTime" ); 263 MutexGuard aGuard(m_aMutex); 264 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 265 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getTime( columnIndex ); 266 } 267 268 //------------------------------------------------------------------------------ 269 ::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 270 { 271 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTimestamp" ); 272 MutexGuard aGuard(m_aMutex); 273 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 274 275 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getTimestamp( columnIndex ); 276 } 277 278 //------------------------------------------------------------------------------ 279 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 280 { 281 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBinaryStream" ); 282 MutexGuard aGuard(m_aMutex); 283 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 284 285 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBinaryStream( columnIndex ); 286 } 287 288 //------------------------------------------------------------------------------ 289 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 290 { 291 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getCharacterStream" ); 292 MutexGuard aGuard(m_aMutex); 293 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 294 295 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getCharacterStream( columnIndex ); 296 } 297 298 //------------------------------------------------------------------------------ 299 Any SAL_CALL OCallableStatement::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) 300 { 301 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getObject" ); 302 MutexGuard aGuard(m_aMutex); 303 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 304 305 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getObject( columnIndex, typeMap ); 306 } 307 308 //------------------------------------------------------------------------------ 309 Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 310 { 311 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getRef" ); 312 MutexGuard aGuard(m_aMutex); 313 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 314 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getRef( columnIndex ); 315 } 316 317 //------------------------------------------------------------------------------ 318 Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 319 { 320 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBlob" ); 321 MutexGuard aGuard(m_aMutex); 322 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 323 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBlob( columnIndex ); 324 } 325 326 //------------------------------------------------------------------------------ 327 Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 328 { 329 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getClob" ); 330 MutexGuard aGuard(m_aMutex); 331 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 332 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getClob( columnIndex ); 333 } 334 335 //------------------------------------------------------------------------------ 336 Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) 337 { 338 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getArray" ); 339 MutexGuard aGuard(m_aMutex); 340 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed); 341 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getArray( columnIndex ); 342 } 343 344 345