1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 30*cdf0e10cSrcweir #include "java/sql/ResultSetMetaData.hxx" 31*cdf0e10cSrcweir #include "java/sql/Connection.hxx" 32*cdf0e10cSrcweir #include "java/tools.hxx" 33*cdf0e10cSrcweir #include <rtl/logfile.hxx> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir using namespace connectivity; 36*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 37*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 38*cdf0e10cSrcweir // using namespace ::com::sun::star::sdbcx; 39*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 40*cdf0e10cSrcweir using namespace ::com::sun::star::container; 41*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #define NULLABLE_UNDEFINED 99 44*cdf0e10cSrcweir //************************************************************** 45*cdf0e10cSrcweir //************ Class: java.sql.ResultSetMetaData 46*cdf0e10cSrcweir //************************************************************** 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir jclass java_sql_ResultSetMetaData::theClass = 0; 49*cdf0e10cSrcweir java_sql_ResultSetMetaData::java_sql_ResultSetMetaData( JNIEnv * pEnv, jobject myObj, const java::sql::ConnectionLog& _rResultSetLogger, java_sql_Connection& _rCon ) 50*cdf0e10cSrcweir :java_lang_Object( pEnv, myObj ) 51*cdf0e10cSrcweir ,m_aLogger( _rResultSetLogger ) 52*cdf0e10cSrcweir ,m_pConnection( &_rCon ) 53*cdf0e10cSrcweir ,m_nColumnCount(-1) 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::java_sql_ResultSetMetaData" ); 56*cdf0e10cSrcweir SDBThreadAttach::addRef(); 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir java_sql_ResultSetMetaData::~java_sql_ResultSetMetaData() 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir SDBThreadAttach::releaseRef(); 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir jclass java_sql_ResultSetMetaData::getMyClass() const 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getMyClass" ); 66*cdf0e10cSrcweir // die Klasse muss nur einmal geholt werden, daher statisch 67*cdf0e10cSrcweir if( !theClass ) 68*cdf0e10cSrcweir theClass = findMyClass("java/sql/ResultSetMetaData"); 69*cdf0e10cSrcweir return theClass; 70*cdf0e10cSrcweir } 71*cdf0e10cSrcweir // ------------------------------------------------------------------------- 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnDisplaySize" ); 76*cdf0e10cSrcweir static jmethodID mID(NULL); 77*cdf0e10cSrcweir return callIntMethodWithIntArg("getColumnDisplaySize",mID,column); 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir // ------------------------------------------------------------------------- 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnType" ); 84*cdf0e10cSrcweir static jmethodID mID(NULL); 85*cdf0e10cSrcweir return callIntMethodWithIntArg("getColumnType",mID,column); 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir // ------------------------------------------------------------------------- 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnCount" ); 92*cdf0e10cSrcweir if ( m_nColumnCount == -1 ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir static jmethodID mID(NULL); 95*cdf0e10cSrcweir m_nColumnCount = callIntMethod("getColumnCount",mID); 96*cdf0e10cSrcweir } // if ( m_nColumnCount == -1 ) 97*cdf0e10cSrcweir return m_nColumnCount; 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir // ------------------------------------------------------------------------- 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_ResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isCaseSensitive" ); 105*cdf0e10cSrcweir static jmethodID mID(NULL); 106*cdf0e10cSrcweir return callBooleanMethodWithIntArg( "isCaseSensitive", mID,column ); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir // ------------------------------------------------------------------------- 109*cdf0e10cSrcweir ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getSchemaName" ); 112*cdf0e10cSrcweir static jmethodID mID(NULL); 113*cdf0e10cSrcweir return callStringMethodWithIntArg("getSchemaName",mID,column); 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir // ------------------------------------------------------------------------- 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnName" ); 120*cdf0e10cSrcweir static jmethodID mID(NULL); 121*cdf0e10cSrcweir return callStringMethodWithIntArg("getColumnName",mID,column); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir // ------------------------------------------------------------------------- 124*cdf0e10cSrcweir ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getTableName" ); 127*cdf0e10cSrcweir static jmethodID mID(NULL); 128*cdf0e10cSrcweir return callStringMethodWithIntArg("getTableName",mID,column); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir // ------------------------------------------------------------------------- 131*cdf0e10cSrcweir ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getCatalogName" ); 134*cdf0e10cSrcweir static jmethodID mID(NULL); 135*cdf0e10cSrcweir return callStringMethodWithIntArg("getCatalogName",mID,column); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir // ------------------------------------------------------------------------- 138*cdf0e10cSrcweir ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnTypeName" ); 141*cdf0e10cSrcweir static jmethodID mID(NULL); 142*cdf0e10cSrcweir return callStringMethodWithIntArg("getColumnTypeName",mID,column); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir // ------------------------------------------------------------------------- 145*cdf0e10cSrcweir ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnLabel" ); 148*cdf0e10cSrcweir static jmethodID mID(NULL); 149*cdf0e10cSrcweir return callStringMethodWithIntArg("getColumnLabel",mID,column); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir // ------------------------------------------------------------------------- 152*cdf0e10cSrcweir ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnServiceName" ); 155*cdf0e10cSrcweir static jmethodID mID(NULL); 156*cdf0e10cSrcweir return callStringMethodWithIntArg("getColumnClassName",mID,column); 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir // ------------------------------------------------------------------------- 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_ResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isCurrency" ); 163*cdf0e10cSrcweir if ( m_pConnection->isIgnoreCurrencyEnabled() ) 164*cdf0e10cSrcweir return sal_False; 165*cdf0e10cSrcweir static jmethodID mID(NULL); 166*cdf0e10cSrcweir return callBooleanMethodWithIntArg( "isCurrency", mID,column ); 167*cdf0e10cSrcweir } 168*cdf0e10cSrcweir // ------------------------------------------------------------------------- 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_ResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isAutoIncrement" ); 173*cdf0e10cSrcweir static jmethodID mID(NULL); 174*cdf0e10cSrcweir return callBooleanMethodWithIntArg( "isAutoIncrement", mID,column ); 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir // ------------------------------------------------------------------------- 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isSigned" ); 182*cdf0e10cSrcweir static jmethodID mID(NULL); 183*cdf0e10cSrcweir return callBooleanMethodWithIntArg( "isSigned", mID,column ); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir // ------------------------------------------------------------------------- 186*cdf0e10cSrcweir sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getPrecision" ); 189*cdf0e10cSrcweir static jmethodID mID(NULL); 190*cdf0e10cSrcweir return callIntMethodWithIntArg("getPrecision",mID,column); 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir // ------------------------------------------------------------------------- 193*cdf0e10cSrcweir sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getScale" ); 196*cdf0e10cSrcweir static jmethodID mID(NULL); 197*cdf0e10cSrcweir return callIntMethodWithIntArg("getScale",mID,column); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir // ------------------------------------------------------------------------- 200*cdf0e10cSrcweir sal_Int32 SAL_CALL java_sql_ResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isNullable" ); 203*cdf0e10cSrcweir static jmethodID mID(NULL); 204*cdf0e10cSrcweir return callIntMethodWithIntArg("isNullable",mID,column); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir // ------------------------------------------------------------------------- 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isSearchable" ); 211*cdf0e10cSrcweir static jmethodID mID(NULL); 212*cdf0e10cSrcweir return callBooleanMethodWithIntArg( "isSearchable", mID,column ); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir // ------------------------------------------------------------------------- 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_ResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isReadOnly" ); 219*cdf0e10cSrcweir static jmethodID mID(NULL); 220*cdf0e10cSrcweir return callBooleanMethodWithIntArg( "isReadOnly", mID,column ); 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir // ------------------------------------------------------------------------- 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_ResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isDefinitelyWritable" ); 227*cdf0e10cSrcweir static jmethodID mID(NULL); 228*cdf0e10cSrcweir return callBooleanMethodWithIntArg( "isDefinitelyWritable", mID,column ); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir // ------------------------------------------------------------------------- 231*cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_ResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isWritable" ); 234*cdf0e10cSrcweir static jmethodID mID(NULL); 235*cdf0e10cSrcweir return callBooleanMethodWithIntArg( "isWritable", mID,column ); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir // ------------------------------------------------------------------------- 238*cdf0e10cSrcweir 239