1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_connectivity.hxx"
26 #include "java/sql/ResultSetMetaData.hxx"
27 #include "java/sql/Connection.hxx"
28 #include "java/tools.hxx"
29 #include <rtl/logfile.hxx>
30 
31 using namespace connectivity;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::beans;
34 //	using namespace ::com::sun::star::sdbcx;
35 using namespace ::com::sun::star::sdbc;
36 using namespace ::com::sun::star::container;
37 using namespace ::com::sun::star::lang;
38 
39 #define NULLABLE_UNDEFINED  99
40 //**************************************************************
41 //************ Class: java.sql.ResultSetMetaData
42 //**************************************************************
43 
44 jclass java_sql_ResultSetMetaData::theClass = 0;
java_sql_ResultSetMetaData(JNIEnv * pEnv,jobject myObj,const java::sql::ConnectionLog & _rResultSetLogger,java_sql_Connection & _rCon)45 java_sql_ResultSetMetaData::java_sql_ResultSetMetaData( JNIEnv * pEnv, jobject myObj, const java::sql::ConnectionLog& _rResultSetLogger, java_sql_Connection& _rCon  )
46     :java_lang_Object( pEnv, myObj )
47     ,m_aLogger( _rResultSetLogger )
48     ,m_pConnection( &_rCon )
49     ,m_nColumnCount(-1)
50 {
51     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::java_sql_ResultSetMetaData" );
52 	SDBThreadAttach::addRef();
53 }
~java_sql_ResultSetMetaData()54 java_sql_ResultSetMetaData::~java_sql_ResultSetMetaData()
55 {
56 	SDBThreadAttach::releaseRef();
57 }
58 
getMyClass() const59 jclass java_sql_ResultSetMetaData::getMyClass() const
60 {
61     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getMyClass" );
62 	// die Klasse muss nur einmal geholt werden, daher statisch
63 	if( !theClass )
64         theClass = findMyClass("java/sql/ResultSetMetaData");
65 	return theClass;
66 }
67 // -------------------------------------------------------------------------
68 
getColumnDisplaySize(sal_Int32 column)69 sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
70 {
71     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnDisplaySize" );
72     static jmethodID mID(NULL);
73     return callIntMethodWithIntArg("getColumnDisplaySize",mID,column);
74 }
75 // -------------------------------------------------------------------------
76 
getColumnType(sal_Int32 column)77 sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
78 {
79     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnType" );
80     static jmethodID mID(NULL);
81     return callIntMethodWithIntArg("getColumnType",mID,column);
82 }
83 // -------------------------------------------------------------------------
84 
getColumnCount()85 sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnCount(  ) throw(SQLException, RuntimeException)
86 {
87     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnCount" );
88     if ( m_nColumnCount == -1 )
89     {
90         static jmethodID mID(NULL);
91         m_nColumnCount = callIntMethod("getColumnCount",mID);
92     } // if ( m_nColumnCount == -1 )
93 	return m_nColumnCount;
94 
95 }
96 // -------------------------------------------------------------------------
97 
isCaseSensitive(sal_Int32 column)98 sal_Bool SAL_CALL java_sql_ResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException)
99 {
100     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isCaseSensitive" );
101     static jmethodID mID(NULL);
102     return callBooleanMethodWithIntArg( "isCaseSensitive", mID,column );
103 }
104 // -------------------------------------------------------------------------
getSchemaName(sal_Int32 column)105 ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException)
106 {
107     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getSchemaName" );
108     static jmethodID mID(NULL);
109     return callStringMethodWithIntArg("getSchemaName",mID,column);
110 }
111 // -------------------------------------------------------------------------
112 
getColumnName(sal_Int32 column)113 ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
114 {
115     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnName" );
116     static jmethodID mID(NULL);
117     return callStringMethodWithIntArg("getColumnName",mID,column);
118 }
119 // -------------------------------------------------------------------------
getTableName(sal_Int32 column)120 ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException)
121 {
122     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getTableName" );
123     static jmethodID mID(NULL);
124     return callStringMethodWithIntArg("getTableName",mID,column);
125 }
126 // -------------------------------------------------------------------------
getCatalogName(sal_Int32 column)127 ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException)
128 {
129     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getCatalogName" );
130     static jmethodID mID(NULL);
131     return callStringMethodWithIntArg("getCatalogName",mID,column);
132 }
133 // -------------------------------------------------------------------------
getColumnTypeName(sal_Int32 column)134 ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
135 {
136     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnTypeName" );
137     static jmethodID mID(NULL);
138     return callStringMethodWithIntArg("getColumnTypeName",mID,column);
139 }
140 // -------------------------------------------------------------------------
getColumnLabel(sal_Int32 column)141 ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
142 {
143     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnLabel" );
144     static jmethodID mID(NULL);
145     return callStringMethodWithIntArg("getColumnLabel",mID,column);
146 }
147 // -------------------------------------------------------------------------
getColumnServiceName(sal_Int32 column)148 ::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException)
149 {
150     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnServiceName" );
151     static jmethodID mID(NULL);
152     return callStringMethodWithIntArg("getColumnClassName",mID,column);
153 }
154 // -------------------------------------------------------------------------
155 
isCurrency(sal_Int32 column)156 sal_Bool SAL_CALL java_sql_ResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
157 {
158     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isCurrency" );
159     if ( m_pConnection->isIgnoreCurrencyEnabled() )
160         return sal_False;
161     static jmethodID mID(NULL);
162     return callBooleanMethodWithIntArg( "isCurrency", mID,column );
163 }
164 // -------------------------------------------------------------------------
165 
isAutoIncrement(sal_Int32 column)166 sal_Bool SAL_CALL java_sql_ResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
167 {
168     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isAutoIncrement" );
169     static jmethodID mID(NULL);
170     return callBooleanMethodWithIntArg( "isAutoIncrement", mID,column );
171 }
172 // -------------------------------------------------------------------------
173 
174 
isSigned(sal_Int32 column)175 sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException)
176 {
177     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isSigned" );
178     static jmethodID mID(NULL);
179     return callBooleanMethodWithIntArg( "isSigned", mID,column );
180 }
181 // -------------------------------------------------------------------------
getPrecision(sal_Int32 column)182 sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
183 {
184     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getPrecision" );
185     static jmethodID mID(NULL);
186     return callIntMethodWithIntArg("getPrecision",mID,column);
187 }
188 // -------------------------------------------------------------------------
getScale(sal_Int32 column)189 sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
190 {
191     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getScale" );
192     static jmethodID mID(NULL);
193     return callIntMethodWithIntArg("getScale",mID,column);
194 }
195 // -------------------------------------------------------------------------
isNullable(sal_Int32 column)196 sal_Int32 SAL_CALL java_sql_ResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
197 {
198     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isNullable" );
199     static jmethodID mID(NULL);
200     return callIntMethodWithIntArg("isNullable",mID,column);
201 }
202 // -------------------------------------------------------------------------
203 
isSearchable(sal_Int32 column)204 sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException)
205 {
206     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isSearchable" );
207     static jmethodID mID(NULL);
208     return callBooleanMethodWithIntArg( "isSearchable", mID,column );
209 }
210 // -------------------------------------------------------------------------
211 
isReadOnly(sal_Int32 column)212 sal_Bool SAL_CALL java_sql_ResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
213 {
214     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isReadOnly" );
215     static jmethodID mID(NULL);
216     return callBooleanMethodWithIntArg( "isReadOnly", mID,column );
217 }
218 // -------------------------------------------------------------------------
219 
isDefinitelyWritable(sal_Int32 column)220 sal_Bool SAL_CALL java_sql_ResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
221 {
222     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isDefinitelyWritable" );
223     static jmethodID mID(NULL);
224     return callBooleanMethodWithIntArg( "isDefinitelyWritable", mID,column );
225 }
226 // -------------------------------------------------------------------------
isWritable(sal_Int32 column)227 sal_Bool SAL_CALL java_sql_ResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
228 {
229     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isWritable" );
230     static jmethodID mID(NULL);
231     return callBooleanMethodWithIntArg( "isWritable", mID,column );
232 }
233 // -------------------------------------------------------------------------
234 
235