1 5 package org.h2.jdbc; 6 7 import java.sql.*; 8 9 import org.h2.command.CommandInterface; 10 import org.h2.engine.SessionInterface; 11 import org.h2.message.Message; 12 import org.h2.message.TraceObject; 13 14 17 public class JdbcParameterMetaData extends TraceObject 18 implements ParameterMetaData 20 { 22 23 private JdbcPreparedStatement prep; 24 private int paramCount; 25 26 31 public int getParameterCount() throws SQLException { 32 try { 33 debugCodeCall("getParameterCount"); 34 checkClosed(); 35 return paramCount; 36 } catch(Throwable e) { 37 throw logAndConvert(e); 38 } 39 } 40 41 47 public int getParameterMode(int param) throws SQLException { 49 try { 50 debugCodeCall("getParameterMode", param); 51 checkParameterIndex(param); 52 return parameterModeIn; 53 } catch(Throwable e) { 54 throw logAndConvert(e); 55 } 56 } 57 59 65 public int getParameterType(int param) throws SQLException { 66 try { 67 debugCodeCall("getParameterType", param); 68 checkParameterIndex(param); 69 return Types.VARCHAR; 70 } catch(Throwable e) { 71 throw logAndConvert(e); 72 } 73 } 74 75 81 public int getPrecision(int param) throws SQLException { 82 try { 83 debugCodeCall("getPrecision", param); 84 checkParameterIndex(param); 85 return 0; 86 } catch(Throwable e) { 87 throw logAndConvert(e); 88 } 89 } 90 91 97 public int getScale(int param) throws SQLException { 98 try { 99 debugCodeCall("getScale", param); 100 checkParameterIndex(param); 101 return 0; 102 } catch(Throwable e) { 103 throw logAndConvert(e); 104 } 105 } 106 107 113 public int isNullable(int param) throws SQLException { 114 try { 115 debugCodeCall("isNullable", param); 116 checkParameterIndex(param); 117 return ResultSetMetaData.columnNullableUnknown; 118 } catch(Throwable e) { 119 throw logAndConvert(e); 120 } 121 } 122 123 129 public boolean isSigned(int param) throws SQLException { 130 try { 131 debugCodeCall("isSigned", param); 132 checkParameterIndex(param); 133 return true; 134 } catch(Throwable e) { 135 throw logAndConvert(e); 136 } 137 } 138 139 145 public String getParameterClassName(int param) throws SQLException { 146 try { 147 debugCodeCall("getParameterClassName", param); 148 checkParameterIndex(param); 149 return String .class.getName(); 150 } catch(Throwable e) { 151 throw logAndConvert(e); 152 } 153 } 154 155 161 public String getParameterTypeName(int param) throws SQLException { 162 try { 163 debugCodeCall("getParameterTypeName", param); 164 checkParameterIndex(param); 165 return "VARCHAR"; 166 } catch(Throwable e) { 167 throw logAndConvert(e); 168 } 169 } 170 171 JdbcParameterMetaData(SessionInterface session, JdbcPreparedStatement prep, CommandInterface command, int id) { 172 setTrace(session.getTrace(), TraceObject.PARAMETER_META_DATA, id); 173 this.prep = prep; 174 this.paramCount = command.getParameters().size(); 175 } 176 177 void checkParameterIndex(int param) throws SQLException { 178 checkClosed(); 179 if (param < 1 || param > paramCount) { 180 throw Message.getInvalidValueException("" + param, "param"); 181 } 182 } 183 184 void checkClosed() throws SQLException { 185 prep.checkClosed(); 186 } 187 188 192 199 201 205 212 214 } 215 | Popular Tags |