2000-09-18 15:18:56 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 08:27:11 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 08:27:11 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 08:27:11 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 08:27:11 +00:00
|
|
|
* $RCSfile: PreparedStatement.cxx,v $
|
2008-10-01 12:28:29 +00:00
|
|
|
* $Revision: 1.24.56.1 $
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 08:27:11 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 08:27:11 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 08:27:11 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-10 08:27:11 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 01:47:47 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_connectivity.hxx"
|
2000-09-18 15:18:56 +00:00
|
|
|
#include "java/sql/PreparedStatement.hxx"
|
|
|
|
#include "java/sql/ResultSet.hxx"
|
2001-01-09 11:58:40 +00:00
|
|
|
#include "java/sql/ResultSetMetaData.hxx"
|
2000-09-18 15:18:56 +00:00
|
|
|
#include "java/sql/Connection.hxx"
|
|
|
|
#include "java/sql/Timestamp.hxx"
|
2008-01-30 06:54:54 +00:00
|
|
|
#include "java/math/BigDecimal.hxx"
|
2000-09-18 15:18:56 +00:00
|
|
|
#include "java/tools.hxx"
|
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
2000-10-11 09:48:50 +00:00
|
|
|
#include <comphelper/sequence.hxx>
|
2001-07-04 09:54:31 +00:00
|
|
|
#include "connectivity/dbtools.hxx"
|
2009-02-17 15:39:54 +00:00
|
|
|
#include "connectivity/FValue.hxx"
|
2001-07-04 09:54:31 +00:00
|
|
|
#include "connectivity/dbexception.hxx"
|
2007-06-27 13:36:57 +00:00
|
|
|
#include "resource/jdbc_log.hrc"
|
2008-10-01 12:28:29 +00:00
|
|
|
#include "resource/common_res.hrc"
|
|
|
|
#include "resource/sharedresources.hxx"
|
2000-09-18 15:18:56 +00:00
|
|
|
|
2008-02-04 12:30:09 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
using namespace connectivity;
|
|
|
|
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;
|
|
|
|
|
|
|
|
//**************************************************************
|
|
|
|
//************ Class: java.sql.PreparedStatement
|
|
|
|
//**************************************************************
|
|
|
|
IMPLEMENT_SERVICE_INFO(java_sql_PreparedStatement,"com.sun.star.sdbcx.JPreparedStatement","com.sun.star.sdbc.PreparedStatement");
|
|
|
|
|
2007-06-27 13:36:57 +00:00
|
|
|
java_sql_PreparedStatement::java_sql_PreparedStatement( JNIEnv * pEnv, java_sql_Connection& _rCon, const ::rtl::OUString& sql )
|
|
|
|
: OStatement_BASE2( pEnv, _rCon )
|
2002-07-25 06:21:56 +00:00
|
|
|
{
|
|
|
|
m_sSqlStatement = sql;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 15:18:56 +00:00
|
|
|
jclass java_sql_PreparedStatement::theClass = 0;
|
|
|
|
|
|
|
|
java_sql_PreparedStatement::~java_sql_PreparedStatement()
|
2002-07-25 06:21:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
jclass java_sql_PreparedStatement::getMyClass()
|
|
|
|
{
|
|
|
|
// die Klasse muss nur einmal geholt werden, daher statisch
|
2001-05-17 08:15:34 +00:00
|
|
|
if( !theClass )
|
|
|
|
{
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2001-05-17 08:15:34 +00:00
|
|
|
if( t.pEnv )
|
|
|
|
{
|
|
|
|
jclass tempClass = t.pEnv->FindClass("java/sql/PreparedStatement"); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
|
|
|
|
jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
|
|
|
|
t.pEnv->DeleteLocalRef( tempClass );
|
|
|
|
saveClassRef( globClass );
|
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
return theClass;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void java_sql_PreparedStatement::saveClassRef( jclass pClass )
|
|
|
|
{
|
2003-04-24 12:21:18 +00:00
|
|
|
if( pClass==0 )
|
2000-09-18 15:18:56 +00:00
|
|
|
return;
|
|
|
|
// der uebergebe Klassen-Handle ist schon global, daher einfach speichern
|
|
|
|
theClass = pClass;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
::com::sun::star::uno::Any SAL_CALL java_sql_PreparedStatement::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
::com::sun::star::uno::Any aRet = OStatement_BASE2::queryInterface(rType);
|
2001-08-24 05:19:41 +00:00
|
|
|
return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType,
|
2000-09-18 15:18:56 +00:00
|
|
|
static_cast< XPreparedStatement*>(this),
|
|
|
|
static_cast< XParameters*>(this),
|
2001-07-04 09:54:31 +00:00
|
|
|
static_cast< XResultSetMetaDataSupplier*>(this),
|
2000-09-18 15:18:56 +00:00
|
|
|
static_cast< XPreparedBatchExecution*>(this));
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_PreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ),
|
|
|
|
::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ),
|
2001-01-09 11:58:40 +00:00
|
|
|
::getCppuType( (const ::com::sun::star::uno::Reference< XResultSetMetaDataSupplier > *)0 ),
|
2000-09-18 15:18:56 +00:00
|
|
|
::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedBatchExecution > *)0 ));
|
|
|
|
|
2000-10-11 09:48:50 +00:00
|
|
|
return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE2::getTypes());
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL java_sql_PreparedStatement::execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-11-21 14:04:04 +00:00
|
|
|
m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
jboolean out(sal_False);
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "()Z";
|
|
|
|
static const char * cMethodName = "execute";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
|
|
|
out = t.pEnv->CallBooleanMethod( object, mID);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL java_sql_PreparedStatement::executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-11-21 14:04:04 +00:00
|
|
|
m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED_UPDATE );
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
jint out(0);
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "()I";
|
|
|
|
static const char * cMethodName = "executeUpdate";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
|
|
|
out = t.pEnv->CallIntMethod( object, mID);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
return (sal_Int32)out;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_STRING_PARAMETER, parameterIndex, x );
|
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2003-04-24 12:21:18 +00:00
|
|
|
if( t.pEnv ){ // temporaere Variable initialisieren
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(ILjava/lang/String;)V";
|
|
|
|
static const char * cMethodName = "setString";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2004-11-09 11:13:11 +00:00
|
|
|
jstring str = convertwchar_tToJavaString(t.pEnv,x);
|
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,str);
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
2004-11-09 11:13:11 +00:00
|
|
|
t.pEnv->DeleteLocalRef(str);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL java_sql_PreparedStatement::getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return (Reference< XConnection >)m_pConnection;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_PreparedStatement::executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-11-21 14:04:04 +00:00
|
|
|
m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED_QUERY );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
jobject out(0);
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "()Ljava/sql/ResultSet;";
|
|
|
|
static const char * cMethodName = "executeQuery";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
|
|
|
out = t.pEnv->CallObjectMethod( object, mID);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-27 11:02:47 +00:00
|
|
|
return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this);
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_BOOLEAN_PARAMETER, parameterIndex, x );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(IZ)V";
|
|
|
|
static const char * cMethodName = "setBoolean";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2001-07-04 09:54:31 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_BYTE_PARAMETER, parameterIndex, (sal_Int32)x );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(IB)V";
|
|
|
|
static const char * cMethodName = "setByte";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2001-07-04 09:54:31 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_DATE_PARAMETER, parameterIndex, x );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2001-07-04 09:54:31 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(ILjava/sql/Date;)V";
|
|
|
|
static const char * cMethodName = "setDate";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2004-11-09 11:13:11 +00:00
|
|
|
jvalue args[1];
|
2001-07-04 09:54:31 +00:00
|
|
|
// Parameter konvertieren
|
|
|
|
java_sql_Date aT(x);
|
2004-11-09 11:13:11 +00:00
|
|
|
args[0].l = aT.getJavaObject();
|
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,args[0].l);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_TIME_PARAMETER, parameterIndex, x );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2001-07-04 09:54:31 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(ILjava/sql/Time;)V";
|
|
|
|
static const char * cMethodName = "setTime";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2001-07-04 09:54:31 +00:00
|
|
|
jvalue args[2];
|
|
|
|
// Parameter konvertieren
|
|
|
|
args[0].i = (sal_Int32)parameterIndex;
|
|
|
|
java_sql_Time aT(x);
|
|
|
|
args[1].l = aT.getJavaObject();
|
2004-11-09 11:13:11 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,args[1].l);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_TIMESTAMP_PARAMETER, parameterIndex, x );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2001-07-04 09:54:31 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(ILjava/sql/Timestamp;)V";
|
|
|
|
static const char * cMethodName = "setTimestamp";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2004-11-09 11:13:11 +00:00
|
|
|
jvalue args[1];
|
2001-07-04 09:54:31 +00:00
|
|
|
// Parameter konvertieren
|
|
|
|
java_sql_Timestamp aT(x);
|
2004-11-09 11:13:11 +00:00
|
|
|
args[0].l = aT.getJavaObject();
|
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,args[0].l);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_DOUBLE_PARAMETER, parameterIndex, x );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(ID)V";
|
|
|
|
static const char * cMethodName = "setDouble";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2001-07-04 09:54:31 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_FLOAT_PARAMETER, parameterIndex, x );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(IF)V";
|
|
|
|
static const char * cMethodName = "setFloat";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2001-07-04 09:54:31 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_INT_PARAMETER, parameterIndex, x );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(II)V";
|
|
|
|
static const char * cMethodName = "setInt";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2001-07-04 09:54:31 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_LONG_PARAMETER, parameterIndex, x );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(IJ)V";
|
|
|
|
static const char * cMethodName = "setLong";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2001-07-04 09:54:31 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_NULL_PARAMETER, parameterIndex, sqlType );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(II)V";
|
|
|
|
static const char * cMethodName = "setNull";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2001-07-04 09:54:31 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-20 00:35:09 +00:00
|
|
|
void SAL_CALL java_sql_PreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-06-20 00:35:09 +00:00
|
|
|
::dbtools::throwFeatureNotImplementedException( "XParameters::setClob", *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-20 00:35:09 +00:00
|
|
|
void SAL_CALL java_sql_PreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-06-20 00:35:09 +00:00
|
|
|
::dbtools::throwFeatureNotImplementedException( "XParameters::setBlob", *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-20 00:35:09 +00:00
|
|
|
void SAL_CALL java_sql_PreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-06-20 00:35:09 +00:00
|
|
|
::dbtools::throwFeatureNotImplementedException( "XParameters::setArray", *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-20 00:35:09 +00:00
|
|
|
void SAL_CALL java_sql_PreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-06-20 00:35:09 +00:00
|
|
|
::dbtools::throwFeatureNotImplementedException( "XParameters::setRef", *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2008-01-30 06:54:54 +00:00
|
|
|
void SAL_CALL java_sql_PreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2008-01-30 06:54:54 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_OBJECT_NULL_PARAMETER, parameterIndex );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2008-01-30 06:54:54 +00:00
|
|
|
|
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
|
|
|
if( t.pEnv ){
|
|
|
|
createStatement(t.pEnv);
|
|
|
|
|
|
|
|
// temporaere Variable initialisieren
|
|
|
|
static const char * cSignature = "(ILjava/lang/Object;II)V";
|
|
|
|
static const char * cMethodName = "setObject";
|
|
|
|
// Java-Call absetzen
|
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
|
|
|
if( mID ){
|
|
|
|
jobject obj = NULL;
|
|
|
|
double nTemp = 0.0;
|
|
|
|
switch(targetSqlType)
|
|
|
|
{
|
|
|
|
case DataType::DECIMAL:
|
|
|
|
case DataType::NUMERIC:
|
|
|
|
{
|
|
|
|
::std::auto_ptr<java_math_BigDecimal> pBigDecimal;
|
|
|
|
if ( x >>= nTemp)
|
|
|
|
{
|
|
|
|
pBigDecimal.reset(new java_math_BigDecimal(nTemp));
|
|
|
|
//setDouble(parameterIndex,nTemp);
|
|
|
|
//return;
|
|
|
|
}
|
|
|
|
else
|
2009-02-17 15:39:54 +00:00
|
|
|
{
|
|
|
|
ORowSetValue aValue;
|
|
|
|
aValue.fill(x);
|
|
|
|
const ::rtl::OUString sValue = aValue;
|
|
|
|
if ( sValue.getLength() )
|
|
|
|
pBigDecimal.reset(new java_math_BigDecimal(sValue));
|
|
|
|
else
|
|
|
|
pBigDecimal.reset(new java_math_BigDecimal(0.0));
|
|
|
|
}
|
2008-01-30 06:54:54 +00:00
|
|
|
//obj = convertwchar_tToJavaString(t.pEnv,::comphelper::getString(x));
|
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,pBigDecimal->getJavaObject(),targetSqlType,scale);
|
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
obj = convertwchar_tToJavaString(t.pEnv,::comphelper::getString(x));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,obj,targetSqlType,scale);
|
|
|
|
t.pEnv->DeleteLocalRef(obj);
|
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
2006-06-20 00:35:09 +00:00
|
|
|
void SAL_CALL java_sql_PreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/, const ::rtl::OUString& /*typeName*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_OBJECT_NULL_PARAMETER, parameterIndex );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2001-07-04 09:54:31 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(ILjava/lang/Object;)V";
|
|
|
|
static const char * cMethodName = "setObject";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2001-07-04 09:54:31 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,0);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2001-07-04 09:54:31 +00:00
|
|
|
if(!::dbtools::implSetObject(this,parameterIndex,x))
|
|
|
|
{
|
2008-10-01 12:28:29 +00:00
|
|
|
const ::rtl::OUString sError( m_pConnection->getResources().getResourceStringWithSubstitution(
|
|
|
|
STR_UNKNOWN_PARA_TYPE,
|
|
|
|
"$position$", ::rtl::OUString::valueOf(parameterIndex)
|
|
|
|
) );
|
|
|
|
::dbtools::throwGenericSQLException(sError,*this);
|
2001-07-04 09:54:31 +00:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_SHORT_PARAMETER, parameterIndex, x );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(IS)V";
|
|
|
|
static const char * cMethodName = "setShort";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2001-07-04 09:54:31 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,x);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_BYTES_PARAMETER, parameterIndex );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2001-07-04 09:54:31 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(I[B)V";
|
|
|
|
static const char * cMethodName = "setBytes";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
2001-07-04 09:54:31 +00:00
|
|
|
jbyteArray pByteArray = t.pEnv->NewByteArray(x.getLength());
|
|
|
|
t.pEnv->SetByteArrayRegion(pByteArray,0,x.getLength(),(jbyte*)x.getConstArray());
|
2004-11-09 11:13:11 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,pByteArray);
|
2001-07-04 09:54:31 +00:00
|
|
|
t.pEnv->DeleteLocalRef(pByteArray);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_CHARSTREAM_PARAMETER, parameterIndex );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(ILjava/io/InputStream;I)V";
|
|
|
|
static const char * cMethodName = "setCharacterStream";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID )
|
2001-07-04 09:54:31 +00:00
|
|
|
{
|
2008-12-01 12:31:27 +00:00
|
|
|
Sequence< sal_Int8 > aSeq;
|
|
|
|
if ( x.is() )
|
|
|
|
x->readBytes( aSeq, length );
|
|
|
|
sal_Int32 actualLength = aSeq.getLength();
|
|
|
|
|
2001-07-04 09:54:31 +00:00
|
|
|
jvalue args2[3];
|
2008-12-01 12:31:27 +00:00
|
|
|
jbyteArray pByteArray = t.pEnv->NewByteArray( actualLength );
|
|
|
|
t.pEnv->SetByteArrayRegion(pByteArray,0,actualLength,(jbyte*)aSeq.getConstArray());
|
2001-07-04 09:54:31 +00:00
|
|
|
args2[0].l = pByteArray;
|
|
|
|
args2[1].i = 0;
|
2008-12-01 12:31:27 +00:00
|
|
|
args2[2].i = actualLength;
|
2001-07-04 09:54:31 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
const char * cSignatureStream = "([BII)V";
|
2001-07-04 09:54:31 +00:00
|
|
|
// Java-Call absetzen
|
|
|
|
jclass aClass = t.pEnv->FindClass("java/io/CharArrayInputStream");
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID2 = NULL;
|
2008-01-30 06:54:54 +00:00
|
|
|
if ( !mID2 )
|
2004-11-09 11:13:11 +00:00
|
|
|
mID2 = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream );
|
2001-07-04 09:54:31 +00:00
|
|
|
jobject tempObj = NULL;
|
|
|
|
if(mID2)
|
|
|
|
tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 );
|
|
|
|
|
2008-12-01 12:31:27 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,tempObj,actualLength);
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
2001-07-04 09:54:31 +00:00
|
|
|
t.pEnv->DeleteLocalRef(pByteArray);
|
|
|
|
t.pEnv->DeleteLocalRef(tempObj);
|
|
|
|
t.pEnv->DeleteLocalRef(aClass);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2001-07-04 09:54:31 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_BINARYSTREAM_PARAMETER, parameterIndex );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(ILjava/io/InputStream;I)V";
|
|
|
|
static const char * cMethodName = "setBinaryStream";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID )
|
2001-07-04 09:54:31 +00:00
|
|
|
{
|
2008-12-01 12:31:27 +00:00
|
|
|
Sequence< sal_Int8 > aSeq;
|
|
|
|
if ( x.is() )
|
|
|
|
x->readBytes( aSeq, length );
|
|
|
|
sal_Int32 actualLength = aSeq.getLength();
|
|
|
|
|
2001-07-04 09:54:31 +00:00
|
|
|
jvalue args2[3];
|
2008-12-01 12:31:27 +00:00
|
|
|
jbyteArray pByteArray = t.pEnv->NewByteArray(actualLength);
|
|
|
|
t.pEnv->SetByteArrayRegion(pByteArray,0,actualLength,(jbyte*)aSeq.getConstArray());
|
2001-07-04 09:54:31 +00:00
|
|
|
args2[0].l = pByteArray;
|
|
|
|
args2[1].i = 0;
|
2008-12-01 12:31:27 +00:00
|
|
|
args2[2].i = (sal_Int32)actualLength;
|
2001-07-04 09:54:31 +00:00
|
|
|
|
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
const char * cSignatureStream = "([BII)V";
|
2001-07-04 09:54:31 +00:00
|
|
|
// Java-Call absetzen
|
|
|
|
jclass aClass = t.pEnv->FindClass("java/io/ByteArrayInputStream");
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID2 = NULL;
|
2008-01-30 06:54:54 +00:00
|
|
|
if ( !mID2 )
|
2004-11-09 11:13:11 +00:00
|
|
|
mID2 = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream );
|
2001-07-04 09:54:31 +00:00
|
|
|
jobject tempObj = NULL;
|
|
|
|
if(mID2)
|
|
|
|
tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 );
|
2008-12-01 12:31:27 +00:00
|
|
|
t.pEnv->CallVoidMethod( object, mID, parameterIndex,tempObj,(sal_Int32)actualLength);
|
2000-09-18 15:18:56 +00:00
|
|
|
// und aufraeumen
|
2001-07-04 09:54:31 +00:00
|
|
|
t.pEnv->DeleteLocalRef(pByteArray);
|
|
|
|
t.pEnv->DeleteLocalRef(tempObj);
|
|
|
|
t.pEnv->DeleteLocalRef(aClass);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2001-07-04 09:54:31 +00:00
|
|
|
}
|
2000-09-18 15:18:56 +00:00
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-06-27 13:36:57 +00:00
|
|
|
m_aLogger.log( LogLevel::FINER, STR_LOG_CLEAR_PARAMETERS );
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2007-06-27 13:36:57 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
SDBThreadAttach t;
|
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "()V";
|
|
|
|
static const char * cMethodName = "clearParameters";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
|
|
|
t.pEnv->CallVoidMethod( object, mID);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "()V";
|
|
|
|
static const char * cMethodName = "clearBatch";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
|
|
|
t.pEnv->CallVoidMethod( object, mID);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL java_sql_PreparedStatement::addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "()V";
|
|
|
|
static const char * cMethodName = "addBatch";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
|
|
|
t.pEnv->CallVoidMethod( object, mID );
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
|
|
::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL java_sql_PreparedStatement::executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2000-09-18 15:18:56 +00:00
|
|
|
::com::sun::star::uno::Sequence< sal_Int32 > aSeq;
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( t.pEnv ){
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2000-09-18 15:18:56 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "()[I";
|
|
|
|
static const char * cMethodName = "executeBatch";
|
2000-09-18 15:18:56 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2000-09-18 15:18:56 +00:00
|
|
|
if( mID ){
|
|
|
|
jintArray out = (jintArray)t.pEnv->CallObjectMethod( object, mID );
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
2000-09-18 15:18:56 +00:00
|
|
|
if(out)
|
|
|
|
{
|
|
|
|
jboolean p = sal_False;
|
|
|
|
aSeq.realloc(t.pEnv->GetArrayLength(out));
|
|
|
|
memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength());
|
|
|
|
t.pEnv->DeleteLocalRef(out);
|
|
|
|
}
|
|
|
|
} //mID
|
|
|
|
} //t.pEnv
|
|
|
|
return aSeq;
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
2001-01-09 11:58:40 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL java_sql_PreparedStatement::getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2009-02-17 15:39:54 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
2001-01-09 11:58:40 +00:00
|
|
|
jobject out(0);
|
2005-02-16 16:28:56 +00:00
|
|
|
SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
|
2001-01-09 11:58:40 +00:00
|
|
|
if( t.pEnv )
|
|
|
|
{
|
2004-11-09 11:13:11 +00:00
|
|
|
createStatement(t.pEnv);
|
2001-01-09 11:58:40 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "()Ljava/sql/ResultSetMetaData;";
|
|
|
|
static const char * cMethodName = "getMetaData";
|
2001-01-09 11:58:40 +00:00
|
|
|
// Java-Call absetzen
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = t.pEnv->GetMethodID( getMyClass(), cMethodName, cSignature );OSL_ENSURE(mID,"Unknown method id!");
|
2001-01-09 11:58:40 +00:00
|
|
|
if( mID ){
|
|
|
|
out = t.pEnv->CallObjectMethod( object, mID );
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-27 11:02:47 +00:00
|
|
|
return out==0 ? 0 : new java_sql_ResultSetMetaData( t.pEnv, out, m_aLogger,*m_pConnection );
|
2001-01-09 11:58:40 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-04-30 09:16:19 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
2001-10-17 12:40:26 +00:00
|
|
|
void SAL_CALL java_sql_PreparedStatement::acquire() throw()
|
2001-04-30 09:16:19 +00:00
|
|
|
{
|
|
|
|
OStatement_BASE2::acquire();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-10-17 12:40:26 +00:00
|
|
|
void SAL_CALL java_sql_PreparedStatement::release() throw()
|
2001-04-30 09:16:19 +00:00
|
|
|
{
|
|
|
|
OStatement_BASE2::release();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2004-11-09 11:13:11 +00:00
|
|
|
void java_sql_PreparedStatement::createStatement(JNIEnv* _pEnv)
|
2003-04-24 12:21:18 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
|
|
|
|
|
2004-11-09 11:13:11 +00:00
|
|
|
if( !object && _pEnv ){
|
2003-04-24 12:21:18 +00:00
|
|
|
// temporaere Variable initialisieren
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature = "(Ljava/lang/String;II)Ljava/sql/PreparedStatement;";
|
|
|
|
static const char * cMethodName = "prepareStatement";
|
2003-04-24 12:21:18 +00:00
|
|
|
|
|
|
|
jvalue args[1];
|
|
|
|
// Parameter konvertieren
|
2004-11-09 11:13:11 +00:00
|
|
|
args[0].l = convertwchar_tToJavaString(_pEnv,m_sSqlStatement);
|
2003-04-24 12:21:18 +00:00
|
|
|
// Java-Call absetzen
|
|
|
|
jobject out = NULL;
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID = NULL;
|
|
|
|
if ( !mID )
|
|
|
|
mID = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
|
2003-04-24 12:21:18 +00:00
|
|
|
if( mID )
|
|
|
|
{
|
2004-11-09 11:13:11 +00:00
|
|
|
out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, args[0].l ,m_nResultSetType,m_nResultSetConcurrency);
|
2003-04-24 12:21:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-20 00:35:09 +00:00
|
|
|
static const char * cSignature2 = "(Ljava/lang/String;)Ljava/sql/PreparedStatement;";
|
2004-11-09 11:13:11 +00:00
|
|
|
static jmethodID mID2 = NULL;
|
|
|
|
if ( !mID2)
|
|
|
|
mID2 = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID,"Unknown method id!");
|
|
|
|
if ( mID2 )
|
|
|
|
out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, args[0].l );
|
2003-04-24 12:21:18 +00:00
|
|
|
}
|
2004-11-09 11:13:11 +00:00
|
|
|
_pEnv->DeleteLocalRef((jstring)args[0].l);
|
2007-06-27 13:36:57 +00:00
|
|
|
ThrowLoggedSQLException( m_aLogger, _pEnv, *this );
|
2003-04-24 12:21:18 +00:00
|
|
|
if ( out )
|
2004-11-09 11:13:11 +00:00
|
|
|
object = _pEnv->NewGlobalRef( out );
|
2003-04-24 12:21:18 +00:00
|
|
|
} //t.pEnv
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2001-01-09 11:58:40 +00:00
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
|