LibreOffice Module connectivity (master) 1
jdbc/ResultSetMetaData.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
22
23using namespace connectivity;
24using namespace ::com::sun::star::uno;
25using namespace ::com::sun::star::beans;
26using namespace ::com::sun::star::sdbc;
27using namespace ::com::sun::star::container;
28using namespace ::com::sun::star::lang;
29
30
31//************ Class: java.sql.ResultSetMetaData
32
33
34jclass java_sql_ResultSetMetaData::theClass = nullptr;
35java_sql_ResultSetMetaData::java_sql_ResultSetMetaData( JNIEnv * pEnv, jobject myObj, java_sql_Connection& _rCon )
36 :java_lang_Object( pEnv, myObj )
37 ,m_pConnection( &_rCon )
38 ,m_nColumnCount(-1)
39{
41}
43{
45}
46
48{
49 // The class needs to be fetched just once, that is why it is static
50 if( !theClass )
51 theClass = findMyClass("java/sql/ResultSetMetaData");
52 return theClass;
53}
54
55
56sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnDisplaySize( sal_Int32 column )
57{
58 static jmethodID mID(nullptr);
59 return callIntMethodWithIntArg_ThrowSQL("getColumnDisplaySize",mID,column);
60}
61
62
63sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnType( sal_Int32 column )
64{
65 static jmethodID mID(nullptr);
66 return callIntMethodWithIntArg_ThrowSQL("getColumnType",mID,column);
67}
68
69
71{
72 if ( m_nColumnCount == -1 )
73 {
74 static jmethodID mID(nullptr);
75 m_nColumnCount = callIntMethod_ThrowSQL("getColumnCount", mID);
76 } // if ( m_nColumnCount == -1 )
77 return m_nColumnCount;
78
79}
80
81
83{
84 static jmethodID mID(nullptr);
85 return callBooleanMethodWithIntArg( "isCaseSensitive", mID,column );
86}
87
88OUString SAL_CALL java_sql_ResultSetMetaData::getSchemaName( sal_Int32 column )
89{
90 static jmethodID mID(nullptr);
91 return callStringMethodWithIntArg("getSchemaName",mID,column);
92}
93
94
95OUString SAL_CALL java_sql_ResultSetMetaData::getColumnName( sal_Int32 column )
96{
97 static jmethodID mID(nullptr);
98 return callStringMethodWithIntArg("getColumnName",mID,column);
99}
100
101OUString SAL_CALL java_sql_ResultSetMetaData::getTableName( sal_Int32 column )
102{
103 static jmethodID mID(nullptr);
104 return callStringMethodWithIntArg("getTableName",mID,column);
105}
106
107OUString SAL_CALL java_sql_ResultSetMetaData::getCatalogName( sal_Int32 column )
108{
109 static jmethodID mID(nullptr);
110 return callStringMethodWithIntArg("getCatalogName",mID,column);
111}
112
113OUString SAL_CALL java_sql_ResultSetMetaData::getColumnTypeName( sal_Int32 column )
114{
115 static jmethodID mID(nullptr);
116 return callStringMethodWithIntArg("getColumnTypeName",mID,column);
117}
118
119OUString SAL_CALL java_sql_ResultSetMetaData::getColumnLabel( sal_Int32 column )
120{
121 static jmethodID mID(nullptr);
122 return callStringMethodWithIntArg("getColumnLabel",mID,column);
123}
124
125OUString SAL_CALL java_sql_ResultSetMetaData::getColumnServiceName( sal_Int32 column )
126{
127 static jmethodID mID(nullptr);
128 return callStringMethodWithIntArg("getColumnClassName",mID,column);
129}
130
131
133{
135 return false;
136 static jmethodID mID(nullptr);
137 return callBooleanMethodWithIntArg( "isCurrency", mID,column );
138}
139
140
142{
143 static jmethodID mID(nullptr);
144 return callBooleanMethodWithIntArg( "isAutoIncrement", mID,column );
145}
146
147
149{
150 static jmethodID mID(nullptr);
151 return callBooleanMethodWithIntArg( "isSigned", mID,column );
152}
153
154sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getPrecision( sal_Int32 column )
155{
156 static jmethodID mID(nullptr);
157 return callIntMethodWithIntArg_ThrowSQL("getPrecision",mID,column);
158}
159
160sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getScale( sal_Int32 column )
161{
162 static jmethodID mID(nullptr);
163 return callIntMethodWithIntArg_ThrowSQL("getScale",mID,column);
164}
165
166sal_Int32 SAL_CALL java_sql_ResultSetMetaData::isNullable( sal_Int32 column )
167{
168 static jmethodID mID(nullptr);
169 return callIntMethodWithIntArg_ThrowSQL("isNullable",mID,column);
170}
171
172
174{
175 static jmethodID mID(nullptr);
176 return callBooleanMethodWithIntArg( "isSearchable", mID,column );
177}
178
179
181{
182 static jmethodID mID(nullptr);
183 return callBooleanMethodWithIntArg( "isReadOnly", mID,column );
184}
185
186
188{
189 static jmethodID mID(nullptr);
190 return callBooleanMethodWithIntArg( "isDefinitelyWritable", mID,column );
191}
192
194{
195 static jmethodID mID(nullptr);
196 return callBooleanMethodWithIntArg( "isWritable", mID,column );
197}
198
199
200/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void releaseRef()
Definition: Object.cxx:81
sal_Int32 callIntMethod_ThrowSQL(const char *_pMethodName, jmethodID &_inout_MethodID) const
Definition: Object.cxx:286
sal_Int32 callIntMethodWithIntArg_ThrowSQL(const char *_pMethodName, jmethodID &_inout_MethodID, sal_Int32 _nArgument) const
Definition: Object.cxx:308
bool callBooleanMethodWithIntArg(const char *_pMethodName, jmethodID &_inout_MethodID, sal_Int32 _nArgument) const
Definition: Object.cxx:266
OUString callStringMethodWithIntArg(const char *_pMethodName, jmethodID &_inout_MethodID, sal_Int32 _nArgument) const
Definition: Object.cxx:424
static jclass findMyClass(const char *_pClassName)
Definition: Object.cxx:466
virtual sal_Bool SAL_CALL isAutoIncrement(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getPrecision(sal_Int32 column) override
virtual sal_Bool SAL_CALL isCaseSensitive(sal_Int32 column) override
virtual OUString SAL_CALL getColumnTypeName(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getScale(sal_Int32 column) override
virtual OUString SAL_CALL getSchemaName(sal_Int32 column) override
virtual sal_Bool SAL_CALL isCurrency(sal_Int32 column) override
virtual jclass getMyClass() const override
virtual sal_Int32 SAL_CALL getColumnType(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getColumnDisplaySize(sal_Int32 column) override
virtual OUString SAL_CALL getColumnName(sal_Int32 column) override
virtual sal_Bool SAL_CALL isSearchable(sal_Int32 column) override
virtual OUString SAL_CALL getColumnServiceName(sal_Int32 column) override
virtual OUString SAL_CALL getTableName(sal_Int32 column) override
virtual sal_Bool SAL_CALL isSigned(sal_Int32 column) override
virtual OUString SAL_CALL getColumnLabel(sal_Int32 column) override
virtual sal_Bool SAL_CALL isReadOnly(sal_Int32 column) override
virtual sal_Int32 SAL_CALL isNullable(sal_Int32 column) override
virtual sal_Bool SAL_CALL isWritable(sal_Int32 column) override
virtual sal_Int32 SAL_CALL getColumnCount() override
virtual sal_Bool SAL_CALL isDefinitelyWritable(sal_Int32 column) override
virtual OUString SAL_CALL getCatalogName(sal_Int32 column) override
unsigned char sal_Bool