Example usage for java.sql Array toString

List of usage examples for java.sql Array toString

Introduction

In this page you can find the example usage for java.sql Array toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.kawanfw.sql.jdbc.ResultSetHttp.java

/**
 * Retrieves the value of the designated column in the current row of this
 * <code>ResultSet</code> object as an <code>Array</code> object in the Java
 * programming language./*from   ww  w .  j  a va2 s  . c o  m*/
 * 
 * @param i
 *            the first column is 1, the second is 2, ...
 * @return an <code>Array</code> object representing the SQL
 *         <code>ARRAY</code> value in the specified column
 * @exception SQLException
 *                if a database access error occurs
 * @since 1.2
 */
@Override
public Array getArray(int i) throws SQLException {
    testIfClosed();
    String s = getValueOfList(i, false);

    if (s == null || s.equalsIgnoreCase("NULL")) {
        return null;
    }

    debug("getArray(i) : " + s);

    ArrayTransporter arrayTransporter = new ArrayTransporter();
    Array array = null;

    try {
        array = arrayTransporter.fromBase64(s);
        debug("array : " + array.toString());
        return array;
    } catch (ClassNotFoundException e) {
        String reason = Tag.PRODUCT_EXCEPTION_RAISED
                + " Impossible to convert BASE64 serialized Array back to Array";
        throw new SQLException(reason, e);
    } catch (Exception e) {
        String methodName = new Object() {
        }.getClass().getEnclosingMethod().getName();
        throw new SQLException("Invalid value for " + methodName + "(): " + "\'" + s + "\'");
    }
}