public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException { setBlob((Object)parameterName, inputStream); }
public void setClob(String parameterName, Reader reader, long length) throws SQLException { setClob((Object)parameterName, reader); }
public boolean wasNull() throws SQLException { checkStatement(); return parameterValue == null; }
public Timestamp getTimestamp(int parameterIndex, java.util.Calendar cal) throws SQLException { Object val = getObject(parameterIndex); return getTimestamp(cal, val); }
@Test public void testSetLobs() throws Exception { CallableStatementImpl mmcs = getCallableStatement(); mmcs.paramsByName = new TreeMap<String, Integer>(); mmcs.paramsByName.put("foo", 2); mmcs.paramsByName.put("bar", 4); mmcs.setBlob(1, Mockito.mock(InputStream.class)); mmcs.setBlob("foo", Mockito.mock(InputStream.class)); mmcs.setNClob(3, Mockito.mock(Reader.class)); mmcs.setBlob("bar", Mockito.mock(InputStream.class), 1); mmcs.setClob(5, Mockito.mock(Reader.class)); List<Object> params = mmcs.getParameterValues(); assertTrue(params.get(0) instanceof Blob); assertTrue(params.get(1) instanceof Blob); assertTrue(params.get(2) instanceof Clob); assertTrue(params.get(3) instanceof Blob); assertTrue(params.get(4) instanceof Clob); }
public Object getObject(String parameterName) throws SQLException { return getObject((Object)parameterName); }
public CallableStatementImpl prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { //Check to see the connection is open checkConnection(); validateResultSetType(resultSetType); validateResultSetConcurrency(resultSetConcurrency); validateSQL(sql); //TODO: implement close cursors at commit // add the statement object to the map CallableStatementImpl newStatement = new CallableStatementImpl(this, sql, resultSetType, resultSetConcurrency); addStatement(newStatement); return newStatement; }
@Test public void testWasNull() throws Exception { CallableStatementImpl mmcs = getCallableStatement(); Map<Integer, Integer> params = new HashMap<Integer, Integer>(); mmcs.outParamIndexMap = params; params.put(Integer.valueOf(1), Integer.valueOf(1)); params.put(Integer.valueOf(2), Integer.valueOf(2)); ResultSetImpl rs = Mockito.mock(ResultSetImpl.class); mmcs.resultSet = rs; Mockito.stub(rs.getOutputParamValue(1)).toReturn(null); Mockito.stub(rs.getOutputParamValue(2)).toReturn(Boolean.TRUE); mmcs.getBoolean(1); assertTrue(mmcs.wasNull()); assertTrue(mmcs.getBoolean(2)); assertFalse(mmcs.wasNull()); }
private Time getTime(java.util.Calendar cal, Object val) throws SQLException { Time value = DataTypeTransformer.getTime(val); if (value == null) { return null; } if (cal != null) { value = TimestampWithTimezone.createTime(value, getDefaultCalendar().getTimeZone(), cal); } return value; }
@Test public void testGetOutputParameter() throws Exception { CallableStatementImpl mmcs = getCallableStatement(); RequestMessage request = new RequestMessage(); request.setExecutionId(1); ResultsMessage resultsMsg = new ResultsMessage(); List<?>[] results = new List[] {Arrays.asList(null, null, null), Arrays.asList(null, 1, 2)}; resultsMsg.setResults(results); resultsMsg.setColumnNames(new String[] { "IntNum", "Out1", "Out2" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ resultsMsg.setDataTypes(new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER }); resultsMsg.setFinalRow(results.length); resultsMsg.setLastRow(results.length); resultsMsg.setFirstRow(1); resultsMsg.setParameters(Arrays.asList(new ParameterInfo(ParameterInfo.RESULT_SET, 1), new ParameterInfo(ParameterInfo.OUT, 1), new ParameterInfo(ParameterInfo.OUT, 1))); mmcs.createResultSet(resultsMsg); assertEquals(1, mmcs.getInt(1)); assertEquals(2, mmcs.getInt(2)); assertEquals(1, mmcs.getInt("Out1")); assertEquals(2, mmcs.getInt("Out2")); }
public java.sql.Date getDate(int parameterIndex) throws SQLException { return getDate(parameterIndex, null); }
@Test public void testUnknownIndex() throws Exception { CallableStatementImpl mmcs = getCallableStatement(); mmcs.outParamIndexMap = new HashMap<Integer, Integer>(); try { mmcs.getBoolean(0); fail("expected exception"); //$NON-NLS-1$ } catch (SQLException e) { assertEquals("Parameter 0 was not found.", e.getMessage()); } }
public Object getObject(int parameterIndex) throws SQLException { return getObject(Integer.valueOf(parameterIndex)); }
public CallableStatementImpl prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { //Check to see the connection is open checkConnection(); validateResultSetType(resultSetType); validateResultSetConcurrency(resultSetConcurrency); validateSQL(sql); //TODO: implement close cursors at commit // add the statement object to the map CallableStatementImpl newStatement = new CallableStatementImpl(this, sql, resultSetType, resultSetConcurrency); addStatement(newStatement); return newStatement; }
public Timestamp getTimestamp(int parameterIndex, java.util.Calendar cal) throws SQLException { Object val = getObject(parameterIndex); return getTimestamp(cal, val); }
private Time getTime(java.util.Calendar cal, Object val) throws SQLException { Time value = DataTypeTransformer.getTime(val); if (value == null) { return null; } if (cal != null) { value = TimestampWithTimezone.createTime(value, getDefaultCalendar().getTimeZone(), cal); } return value; }