Transfers data from String into sql.Blob

@param conn  connection for which sql.Blob object would be created
@param value String
@return sql.Clob from String
@throws SQLException
339181
public static Object convertClob(Connection conn, String value) throws SQLException {
        return convertClob(conn, value.getBytes());
    }
475816
public Blob getBlob(int arg0) throws SQLException {
        try {
            Blob blob = rsetImpl.getBlob(arg0); 
            if (blob != null && freeResourcesOnClose)
                blobs.add(blob); 
            return blob; 
        } catch (SQLException ex) {
            FFDCFilter.processException(ex, "com.ibm.ws.rsadapter.jdbc.WSJdbcResultSet.getBlob", "754", this);
            throw WSJdbcUtil.mapException(this, ex);
        } catch (NullPointerException nullX) {
            // No FFDC code needed; we might be closed.
            throw runtimeXIfNotClosed(nullX);
        }
    }
271378
public synchronized void insert (Connection conn, T obj)
        throws SQLException
    {
        StringBuilder sql = new StringBuilder(
            "insert into " + name + " (" + listOfFields + ") values (?");
        for (int i = 1; i < nColumns; i++) {
            sql.append(",?");
        }
        sql.append(")");
        PreparedStatement insertStmt = conn.prepareStatement(sql.toString());
        bindUpdateVariables(insertStmt, obj, null);
        insertStmt.executeUpdate();
        insertStmt.close();
    }
158142
public static String fromWellFormed(String value) {
        if (value == null) {
            return LogicalValue.ANY.getAbbreviation();
        }
        //return value.replaceAll("\\\\([^0-9A-Za-z])", "$1");
        StringBuilder buffer = new StringBuilder(value);
        char p = ' ';
        for (int x = 0; x < buffer.length() - 1; x++) {
            char c = buffer.charAt(x);
            if (c == '\\' && p != '\\') {
                buffer.delete(x, x + 1);
                x -= 1;
            }
            p = c;
        }
        return buffer.toString();
    }
151341
public String toSqlString(Object value) {
     if (value == null) {
        return "null";
     }
      
     String val = String.valueOf(value);

     if (value instanceof Integer ||
         value instanceof Float ||
         value instanceof Double ||
         value instanceof Long) {
       return val;
     } else if (value instanceof Boolean) {
        return "'" + ((Boolean) value ? "true" : "false") + "'";
     } else if (value instanceof Date) {
        return String.valueOf(((Date) value).getTime());
     } else {
       return "'" + val + "'"; // TODO escape special characters in val here
     }
   }
680645
public static CallableStatement prepareCall(Connection conn, String sql, Object... params) throws SQLException {
		Assert.notBlank(sql, "Sql String must be not blank!");

		sql = sql.trim();
		SqlLog.INSTASNCE.log(sql, params);
		final CallableStatement call = conn.prepareCall(sql);
		fillParams(call, params);
		return call;
	}
1232771
public static byte[] objString2Byte(String value, Charset charset) {
        if (null == value) {
            return null;
        }
        // 获取byte
        return value.getBytes(charset);

    }
1314178
public static Object toBasicType(String value, String type) throws SQLException {

        // Early return from first "if" condition that evaluates to true

        if (value == null) {
            return null;
        }

        if (type == null || type.equals(String.class.getName())) {
            return value;
        }

        if (type.equals(Integer.class.getName()) || type.equals(int.class.getName())) {
            try { return Integer.valueOf(value); }
            catch (NumberFormatException e) {
                throwSQLException(e, "Integer", value);
            }
        }

        if (type.equals(Float.class.getName()) || type.equals(float.class.getName())) {
            try { return Float.valueOf(value); }
            catch (NumberFormatException e) {
                throwSQLException(e, "Float", value);
            }
        }

        if (type.equals(Long.class.getName()) || type.equals(long.class.getName())) {
            try { return Long.valueOf(value); }
            catch (NumberFormatException e) {
                throwSQLException(e, "Long", value);
            }
        }

        if (type.equals(Double.class.getName()) || type.equals(double.class.getName())) {
            try { return Double.valueOf(value); }
            catch (NumberFormatException e) {
                throwSQLException(e, "Double", value);
            }
        }

        if (type.equals(Character.class.getName()) || type.equals(char.class.getName())) {
            if (value.length() != 1) {
                throw new SQLException("Invalid Character value: " + value);
            }
            return value.charAt(0);
        }

        if (type.equals(Byte.class.getName()) || type.equals(byte.class.getName())) {
            try { return Byte.valueOf(value); }
            catch (NumberFormatException e) {
                throwSQLException(e, "Byte", value);
            }
        }

        if (type.equals(Short.class.getName()) || type.equals(short.class.getName())) {
            try { return Short.valueOf(value); }
            catch (NumberFormatException e) {
                throwSQLException(e, "Short", value);
            }
        }

        // Will be "false" if not in correct format...
        if (type.equals(Boolean.class.getName()) || type.equals(boolean.class.getName())) {
            return Boolean.valueOf(value);
        }

        throw new SQLException("Unrecognized property type: " + type);
    }
1087276
public Clob toClob(String stringName, Connection sqlConnection) {
        Clob clobName = null;
        try {
            clobName = sqlConnection.createClob();
            clobName.setString(1, stringName);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            logger.info("Unable to create clob object");
            e.printStackTrace();
        }
        return clobName;
    }
671890
public static int execute(Connection conn, String sql, Object... params) throws SQLException {
		PreparedStatement ps = null;
		try {
			ps = StatementUtil.prepareStatement(conn, sql, params);
			return ps.executeUpdate();
		} finally {
			DbUtil.close(ps);
		}
	}
950376
public static byte[] toByteArray(InputStream input) throws SQLException {
        byte[] result = null;
        ByteArrayOutputStream output = new ByteArrayOutputStream();

        try {
            copy(input, output);
            result = output.toByteArray();
        } catch (IOException ex) {
            throw new MjdbcSQLException(ex);
        }

        TypeHandlerUtils.closeQuietly(output);

        return result;
    }
167736
private byte[] createBytes(InputStream stream, long length) 
        throws SQLException {

        ByteArrayOutputStream buff = null;

        try {
            buff = new ByteArrayOutputStream();

            if (length > 0) IOUtils.copyLarge(stream, buff, 0, length);
            else IOUtils.copy(stream, buff);

            return buff.toByteArray();
        } catch (IOException e) {
            throw new SQLException("Fails to create BLOB", e);
        } finally {
            IOUtils.closeQuietly(buff);
        } // end of finally
    }
727135
public int update(String sql, Object value) {
        Class<?> parameterType = value != null ? value.getClass() : null;
        String msId = msUtils.updateDynamic(sql, parameterType);
        return sqlSession.update(msId, value);
    }
495061
public static byte[] getBlobColumn(final ResultSet rs, final String columnName) throws SQLException {
		try {
			final Blob blob = rs.getBlob(columnName);
			if (blob == null) {
				return null;
			}

			final InputStream is = blob.getBinaryStream();
			final ByteArrayOutputStream bos = new ByteArrayOutputStream();

			if (is == null) {
				return null;
			} else {
				final byte buffer[] = new byte[64];
				int c = is.read(buffer);
				while (c > 0) {
					bos.write(buffer, 0, c);
					c = is.read(buffer);
				}
				return bos.toByteArray();
			}
		} catch (final IOException e) {
			throw new SQLException("Failed to read BLOB column due to IOException: " + e.getMessage());
		}
	}
958139
public static Object convertClob(Connection conn, byte[] value) throws SQLException {
        Object result = (Object) createClob(conn);

        result = convertClob(result, value);

        return result;
    }
741770
public void put(byte[] value) {
		if (value == null) {
			this.compiledStatement.bindNull(compiledStatementBindIndex++);
		} else {
			compiledStatement.bindBlob(compiledStatementBindIndex++, value);
		}
	}
761673
public static final void appendValueToSql(StringBuilder sql, Object value) {
        if (value == null) {
            sql.append("NULL");
        } else if (value instanceof Boolean) {
            Boolean bool = (Boolean)value;
            if (bool) {
                sql.append('1');
            } else {
                sql.append('0');
            }
        } else {
            appendEscapedSQLString(sql, value.toString());
        }
    }