1 | /* |
2 | Copyright (C) 2005 MySQL AB |
3 | |
4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of version 2 of the GNU General Public License as |
6 | published by the Free Software Foundation. |
7 | |
8 | There are special exceptions to the terms and conditions of the GPL |
9 | as it is applied to this software. View the full text of the |
10 | exception in file EXCEPTIONS-CONNECTOR-J in the directory of this |
11 | software distribution. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | |
22 | */ |
23 | |
24 | package com.mysql.jdbc; |
25 | |
26 | import java.sql.ParameterMetaData; |
27 | import java.sql.SQLException; |
28 | |
29 | public class MysqlParameterMetadata implements ParameterMetaData { |
30 | |
31 | ResultSetMetaData metadata = null; |
32 | int parameterCount = 0; |
33 | |
34 | |
35 | MysqlParameterMetadata(Field[] fieldInfo, int parameterCount) { |
36 | this.metadata = new ResultSetMetaData(fieldInfo); |
37 | |
38 | this.parameterCount = parameterCount; |
39 | } |
40 | |
41 | public int getParameterCount() throws SQLException { |
42 | return this.parameterCount; |
43 | } |
44 | |
45 | public int isNullable(int arg0) throws SQLException { |
46 | checkAvailable(); |
47 | |
48 | return this.metadata.isNullable(arg0); |
49 | } |
50 | |
51 | private void checkAvailable() throws SQLException { |
52 | if (this.metadata == null) { |
53 | throw SQLError.createSQLException( |
54 | "Parameter metadata not available for the given statement", |
55 | SQLError.SQL_STATE_DRIVER_NOT_CAPABLE); |
56 | } |
57 | } |
58 | |
59 | public boolean isSigned(int arg0) throws SQLException { |
60 | checkAvailable(); |
61 | |
62 | return (this.metadata.isSigned(arg0)); |
63 | } |
64 | |
65 | public int getPrecision(int arg0) throws SQLException { |
66 | checkAvailable(); |
67 | |
68 | return (this.metadata.getPrecision(arg0)); |
69 | } |
70 | |
71 | public int getScale(int arg0) throws SQLException { |
72 | checkAvailable(); |
73 | |
74 | return (this.metadata.getScale(arg0)); |
75 | } |
76 | |
77 | public int getParameterType(int arg0) throws SQLException { |
78 | checkAvailable(); |
79 | |
80 | return (this.metadata.getColumnType(arg0)); |
81 | } |
82 | |
83 | public String getParameterTypeName(int arg0) throws SQLException { |
84 | checkAvailable(); |
85 | |
86 | return (this.metadata.getColumnTypeName(arg0)); |
87 | } |
88 | |
89 | public String getParameterClassName(int arg0) throws SQLException { |
90 | checkAvailable(); |
91 | |
92 | return (this.metadata.getColumnClassName(arg0)); |
93 | } |
94 | |
95 | public int getParameterMode(int arg0) throws SQLException { |
96 | return parameterModeIn; |
97 | } |
98 | } |