Java Code Examples for java.sql.CallableStatement#getArray()
The following examples show how to use
java.sql.CallableStatement#getArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractCopySQLData.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void setJetel(CallableStatement statement) throws SQLException { Array fieldVal = statement.getArray(fieldSQL); Object obj = fieldVal.getArray(); Object [] objectArray = (Object []) obj; // cast it to an array of objects StringBuffer buffer = new StringBuffer("{"); buffer.append(String.valueOf(objectArray[0])); for (int j=1; j < objectArray.length; j++) { buffer.append(", ").append(String.valueOf(objectArray[j])); } buffer.append("}"); if (statement.wasNull()) { ((StringDataField) field).setValue((Object)null); } else { ((StringDataField) field).setValue(buffer.toString()); } }
Example 2
Source File: ArrayTypeHandler.java From mybatis-types with MIT License | 5 votes |
@Override public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { Array array = cs.getArray(columnIndex); if (array == null) { return empty(); } return fromArray(array); }
Example 3
Source File: TextArrayTypeHandler.java From mmpt with MIT License | 5 votes |
@Override public String[] getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { Array outputArray = cs.getArray(columnIndex); if (outputArray == null) { return null; } return (String[])outputArray.getArray(); }
Example 4
Source File: IntegerArrayTypeHandler.java From mmpt with MIT License | 5 votes |
@Override public Integer[] getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { Array outputArray = cs.getArray(columnIndex); if (outputArray == null) { return null; } return (Integer[])outputArray.getArray(); }
Example 5
Source File: SmallIntArrayTypeHandler.java From mmpt with MIT License | 5 votes |
@Override public Integer[] getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { Array outputArray = cs.getArray(columnIndex); if (outputArray == null) { return null; } return (Integer[])outputArray.getArray(); }
Example 6
Source File: BooleanArrayTypeHandler.java From mmpt with MIT License | 5 votes |
@Override public Boolean[] getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { Array outputArray = cs.getArray(columnIndex); if (outputArray == null) { return null; } return (Boolean[])outputArray.getArray(); }
Example 7
Source File: BigIntArrayTypeHandler.java From mmpt with MIT License | 5 votes |
@Override public Long[] getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { Array outputArray = cs.getArray(columnIndex); if (outputArray == null) { return null; } return (Long[])outputArray.getArray(); }
Example 8
Source File: UUIDArrayTypeHandler.java From mmpt with MIT License | 5 votes |
@Override public UUID[] getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { Array outputArray = cs.getArray(columnIndex); if (outputArray == null) { return null; } return (UUID[])outputArray.getArray(); }
Example 9
Source File: SQLQuery.java From micro-integrator with Apache License 2.0 | 4 votes |
private ParamValue getOutparameterValue(CallableStatement cs, String type, int ordinal) throws DataServiceFault { try { Object elementValue; if (type.equals(DBConstants.DataTypes.STRING)) { elementValue = cs.getString(ordinal); return new ParamValue(elementValue == null ? null : elementValue.toString()); } else if (type.equals(DBConstants.DataTypes.DOUBLE)) { elementValue = cs.getDouble(ordinal); return new ParamValue(elementValue == null ? null : ConverterUtil.convertToString((Double) elementValue)); } else if (type.equals(DBConstants.DataTypes.BIGINT)) { elementValue = cs.getLong(ordinal); return new ParamValue(elementValue == null ? null : ConverterUtil.convertToString((Long) elementValue)); } else if (type.equals(DBConstants.DataTypes.INTEGER)) { elementValue = cs.getInt(ordinal); return new ParamValue(elementValue == null ? null : ConverterUtil.convertToString((Integer) elementValue)); } else if (type.equals(DBConstants.DataTypes.TIME)) { elementValue = cs.getTime(ordinal); return new ParamValue(elementValue == null ? null : this.convertToTimeString((Time) elementValue)); } else if (type.equals(DBConstants.DataTypes.DATE)) { elementValue = cs.getDate(ordinal); return new ParamValue(elementValue == null ? null : ConverterUtil.convertToString((Date) elementValue)); } else if (type.equals(DBConstants.DataTypes.TIMESTAMP)) { if (timeConvertEnabled) { elementValue = cs.getTimestamp(ordinal, calendar); } else { elementValue = cs.getTimestamp(ordinal); } return new ParamValue(elementValue == null ? null : this.convertToTimestampString((Timestamp) elementValue)); } else if (type.equals(DBConstants.DataTypes.BLOB)) { elementValue = cs.getBlob(ordinal); return new ParamValue(elementValue == null ? null : this.getBase64StringFromInputStream(((Blob) elementValue) .getBinaryStream())); } else if (type.equals(DBConstants.DataTypes.CLOB)) { elementValue = cs.getClob(ordinal); return new ParamValue(elementValue == null ? null : deriveValueFromClob((Clob) elementValue)); } else if (type.equals(DBConstants.DataTypes.STRUCT)) { elementValue = cs.getObject(ordinal); return new ParamValue(elementValue == null ? null : (Struct) elementValue); } else if (type.equals(DBConstants.DataTypes.ARRAY)) { Array dataArray = cs.getArray(ordinal); ParamValue paramValue = new ParamValue(ParamValue.PARAM_VALUE_ARRAY); if (dataArray != null) { this.processSQLArray(dataArray, paramValue); } return paramValue; } else if (type.equals(DBConstants.DataTypes.NUMERIC)) { elementValue = cs.getBigDecimal(ordinal); return new ParamValue(elementValue == null ? null : ConverterUtil.convertToString((BigDecimal) elementValue)); } else if (type.equals(DBConstants.DataTypes.BIT)) { elementValue = cs.getBoolean(ordinal); return new ParamValue(elementValue == null ? null : ConverterUtil.convertToString((Boolean) elementValue)); } else if (type.equals(DBConstants.DataTypes.TINYINT)) { elementValue = cs.getByte(ordinal); return new ParamValue(elementValue == null ? null : ConverterUtil.convertToString((Byte) elementValue)); } else if (type.equals(DBConstants.DataTypes.SMALLINT)) { elementValue = cs.getShort(ordinal); return new ParamValue(elementValue == null ? null : ConverterUtil.convertToString((Short) elementValue)); } else if (type.equals(DBConstants.DataTypes.REAL)) { elementValue = cs.getFloat(ordinal); return new ParamValue(elementValue == null ? null : ConverterUtil.convertToString((Float) elementValue)); } else if (type.equals(DBConstants.DataTypes.BINARY)) { elementValue = cs.getBlob(ordinal); return new ParamValue(elementValue == null ? null : this.getBase64StringFromInputStream(((Blob) elementValue) .getBinaryStream())); } else { throw new DataServiceFault("Unsupported data type: " + type); } } catch (SQLException e) { throw new DataServiceFault(e, "Error in getting sql output parameter values."); } }
Example 10
Source File: ArrayTypeHandler.java From tangyuan2 with GNU General Public License v3.0 | 4 votes |
@Override public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { Array array = cs.getArray(columnIndex); return array == null ? null : array.getArray(); }
Example 11
Source File: ArrayTypeHandler.java From mybaties with Apache License 2.0 | 4 votes |
@Override public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { Array array = cs.getArray(columnIndex); return array == null ? null : array.getArray(); }
Example 12
Source File: AbstractCopySQLData.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 4 votes |
@Override public Object getDbValue(CallableStatement statement) throws SQLException { Array fieldVal = statement.getArray(fieldSQL); return statement.wasNull() ? null : fieldVal; }
Example 13
Source File: ArrayTypeHandler.java From mybatis with Apache License 2.0 | 4 votes |
@Override public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException { Array array = cs.getArray(columnIndex); return array == null ? null : array.getArray(); }