summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorOcke Janssen <oj@openoffice.org>2002-11-21 14:46:31 +0000
committerOcke Janssen <oj@openoffice.org>2002-11-21 14:46:31 +0000
commitd680556f78a02d1644afe0352d7887cc78f7b3fd (patch)
treec6de613481192b22733408eb2af96d7a96964880 /connectivity
parent4252e83bcef31f31c8f353a8860e7455944a329f (diff)
#105213# insert parameter name substitution
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/jdbc/JDriver.cxx20
-rw-r--r--connectivity/source/drivers/jdbc/ResultSet.cxx42
-rw-r--r--connectivity/source/inc/java/sql/Connection.hxx22
-rw-r--r--connectivity/source/inc/java/sql/Driver.hxx6
4 files changed, 58 insertions, 32 deletions
diff --git a/connectivity/source/drivers/jdbc/JDriver.cxx b/connectivity/source/drivers/jdbc/JDriver.cxx
index effaa3ef193e..7596c57286be 100644
--- a/connectivity/source/drivers/jdbc/JDriver.cxx
+++ b/connectivity/source/drivers/jdbc/JDriver.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: JDriver.cxx,v $
*
- * $Revision: 1.23 $
+ * $Revision: 1.24 $
*
- * last change: $Author: oj $ $Date: 2002-08-01 07:15:15 $
+ * last change: $Author: oj $ $Date: 2002-11-21 15:46:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -174,7 +174,7 @@ void java_sql_Driver::saveClassRef( jclass pClass )
theClass = pClass;
}
// -----------------------------------------------------------------------------
-void java_sql_Driver::loadDriverFromProperties(const Sequence< PropertyValue >& info,::rtl::OUString& _rsGeneratedValueStatement,sal_Bool& _rbAutoRetrievingEnabled)
+void java_sql_Driver::loadDriverFromProperties(const Sequence< PropertyValue >& info,::rtl::OUString& _rsGeneratedValueStatement,sal_Bool& _rbAutoRetrievingEnabled,sal_Bool& _bParameterSubstitution)
{
// first try if the jdbc driver is alraedy registered at the driver manager
SDBThreadAttach t(getORB()); OSL_ENSURE(t.pEnv,"Java Enviroment gelscht worden!");
@@ -219,6 +219,10 @@ void java_sql_Driver::loadDriverFromProperties(const Sequence< PropertyValue >&
{
pBegin->Value >>= _rsGeneratedValueStatement;
}
+ else if(!pBegin->Name.compareToAscii("ParameterNameSubstitution"))
+ {
+ pBegin->Value >>= _bParameterSubstitution;
+ }
}
}
}
@@ -252,8 +256,9 @@ Reference< XConnection > SAL_CALL java_sql_Driver::connect( const ::rtl::OUStrin
::rtl::OUString sGeneratedValueStatement; // contains the statement which should be used when query for automatically generated values
- sal_Bool bAutoRetrievingEnabled = sal_False; // set to when we should allow to query for generated values
- loadDriverFromProperties(info,sGeneratedValueStatement,bAutoRetrievingEnabled);
+ sal_Bool bAutoRetrievingEnabled = sal_False; // set to <TRUE/> when we should allow to query for generated values
+ sal_Bool bParameterSubstitution = sal_False; // set to <TRUE/> when we should subsitute named paramteres
+ loadDriverFromProperties(info,sGeneratedValueStatement,bAutoRetrievingEnabled,bParameterSubstitution);
jobject out(0);
if( t.pEnv )
@@ -309,7 +314,7 @@ Reference< XConnection > SAL_CALL java_sql_Driver::connect( const ::rtl::OUStrin
} //t.pEnv
// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
Reference< XConnection > xOut;
- return out==0 ? 0 : new java_sql_Connection( t.pEnv, out,this,sGeneratedValueStatement,bAutoRetrievingEnabled );
+ return out==0 ? 0 : new java_sql_Connection( t.pEnv, out,this,sGeneratedValueStatement,bAutoRetrievingEnabled,bParameterSubstitution );
// return xOut;
}
// -------------------------------------------------------------------------
@@ -334,7 +339,8 @@ Sequence< DriverPropertyInfo > SAL_CALL java_sql_Driver::getPropertyInfo( const
// driver was not loaded so far, load it by name
::rtl::OUString sGeneratedValueStatement; // contains the statement which should be used when query for automatically generated values
sal_Bool bAutoRetrievingEnabled = sal_False; // set to when we should allow to query for generated values
- loadDriverFromProperties(info,sGeneratedValueStatement,bAutoRetrievingEnabled);
+ sal_Bool bParameterSubstitution = sal_False; // set to <TRUE/> when we should subsitute named paramteres
+ loadDriverFromProperties(info,sGeneratedValueStatement,bAutoRetrievingEnabled,bParameterSubstitution);
}
if(!object)
diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx
index 548c3b2f4e3b..39b40eda8015 100644
--- a/connectivity/source/drivers/jdbc/ResultSet.cxx
+++ b/connectivity/source/drivers/jdbc/ResultSet.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ResultSet.cxx,v $
*
- * $Revision: 1.16 $
+ * $Revision: 1.17 $
*
- * last change: $Author: oj $ $Date: 2002-11-01 10:58:36 $
+ * last change: $Author: oj $ $Date: 2002-11-21 15:46:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1739,23 +1739,29 @@ void java_sql_ResultSet::getFastPropertyValue(
sal_Int32 nHandle
) const
{
- switch(nHandle)
+ try
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_CURSORNAME:
+ rValue <<= getCursorName();
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ rValue <<= getResultSetConcurrency();
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ rValue <<= getResultSetType();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ rValue <<= getFetchDirection();
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ rValue <<= getFetchSize();
+ break;
+ }
+ }
+ catch(Exception&)
{
- case PROPERTY_ID_CURSORNAME:
- rValue <<= getCursorName();
- break;
- case PROPERTY_ID_RESULTSETCONCURRENCY:
- rValue <<= getResultSetConcurrency();
- break;
- case PROPERTY_ID_RESULTSETTYPE:
- rValue <<= getResultSetType();
- break;
- case PROPERTY_ID_FETCHDIRECTION:
- rValue <<= getFetchDirection();
- break;
- case PROPERTY_ID_FETCHSIZE:
- rValue <<= getFetchSize();
- break;
}
}
// -----------------------------------------------------------------------------
diff --git a/connectivity/source/inc/java/sql/Connection.hxx b/connectivity/source/inc/java/sql/Connection.hxx
index ad337710dedc..80d112d7396e 100644
--- a/connectivity/source/inc/java/sql/Connection.hxx
+++ b/connectivity/source/inc/java/sql/Connection.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Connection.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: oj $ $Date: 2002-10-25 09:05:42 $
+ * last change: $Author: oj $ $Date: 2002-11-21 15:46:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -95,11 +95,20 @@ namespace connectivity
{
friend class OSubComponent<java_sql_Connection, java_sql_Connection_BASE>;
- ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
OWeakRefArray m_aStatements; // vector containing a list
// of all the Statement objects
// for this Connection
java_sql_Driver* m_pDriver;
+ sal_Bool m_bParameterSubstitution;
+
+ /** transform named parameter into unnamed one.
+ @param _sSQL
+ The SQL statement to transform.
+ @return
+ The new statement witgh unnamed parameters.
+ */
+ ::rtl::OUString transFormPreparedStatement(const ::rtl::OUString& _sSQL);
protected:
// statische Daten fuer die Klasse
static jclass theClass;
@@ -118,7 +127,12 @@ namespace connectivity
DECLARE_SERVICE_INFO();
// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
- java_sql_Connection( JNIEnv * pEnv, jobject myObj,java_sql_Driver* _pDriver,const ::rtl::OUString& _sGeneredStmt,sal_Bool _bGenEnabled );
+ java_sql_Connection( JNIEnv * pEnv
+ , jobject myObj
+ ,java_sql_Driver* _pDriver
+ ,const ::rtl::OUString& _sGeneredStmt
+ ,sal_Bool _bGenEnabled
+ ,sal_Bool _bParameterSubstitution);
// OComponentHelper
virtual void SAL_CALL disposing(void);
diff --git a/connectivity/source/inc/java/sql/Driver.hxx b/connectivity/source/inc/java/sql/Driver.hxx
index da3d060caa83..b688c2bd8f44 100644
--- a/connectivity/source/inc/java/sql/Driver.hxx
+++ b/connectivity/source/inc/java/sql/Driver.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: Driver.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: oj $ $Date: 2002-08-01 07:16:25 $
+ * last change: $Author: oj $ $Date: 2002-11-21 15:46:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -91,7 +91,7 @@ namespace connectivity
// der Destruktor um den Object-Counter zu aktualisieren
static void saveClassRef( jclass pClass );
- void loadDriverFromProperties( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info,::rtl::OUString& _rsGeneratedValueStatement,sal_Bool& _rbAutoRetrievingEnabled);
+ void loadDriverFromProperties( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info,::rtl::OUString& _rsGeneratedValueStatement,sal_Bool& _rbAutoRetrievingEnabled,sal_Bool& _bParameterSubstitution);
virtual ~java_sql_Driver();
public: