Câu trả lời dường như được cung cấp dịch vụ liên quan và phụ thuộc tình hình thực hiện của các tài xế. Tôi kiểm tra nguồn của trình điều khiển postgresql hiện tại và có hai cuộc gọi bằng nhau.
Nếu trình điều khiển không biết loại ngoại lệ được ném.
/** code from ./org/postgresql/jdbc2/AbstractJdbc2Statement.java */
public void setObject(int parameterIndex, Object x) throws SQLException
{
checkClosed();
if (x == null)
setNull(parameterIndex, Types.OTHER);
else if (x instanceof String)
setString(parameterIndex, (String)x);
else if (x instanceof BigDecimal)
setBigDecimal(parameterIndex, (BigDecimal)x);
else if (x instanceof Short)
setShort(parameterIndex, ((Short)x).shortValue());
else if (x instanceof Integer)
setInt(parameterIndex, ((Integer)x).intValue());
else if (x instanceof Long)
setLong(parameterIndex, ((Long)x).longValue());
else if (x instanceof Float)
setFloat(parameterIndex, ((Float)x).floatValue());
else if (x instanceof Double)
setDouble(parameterIndex, ((Double)x).doubleValue());
else if (x instanceof byte[])
setBytes(parameterIndex, (byte[])x);
else if (x instanceof java.sql.Date)
setDate(parameterIndex, (java.sql.Date)x);
else if (x instanceof Time)
setTime(parameterIndex, (Time)x);
else if (x instanceof Timestamp)
setTimestamp(parameterIndex, (Timestamp)x);
else if (x instanceof Boolean)
setBoolean(parameterIndex, ((Boolean)x).booleanValue());
else if (x instanceof Byte)
setByte(parameterIndex, ((Byte)x).byteValue());
else if (x instanceof Blob)
setBlob(parameterIndex, (Blob)x);
else if (x instanceof Clob)
setClob(parameterIndex, (Clob)x);
else if (x instanceof Array)
setArray(parameterIndex, (Array)x);
else if (x instanceof PGobject)
setPGobject(parameterIndex, (PGobject)x);
else if (x instanceof Character)
setString(parameterIndex, ((Character)x).toString());
else if (x instanceof Map)
setMap(parameterIndex, (Map)x);
else
{
// Can't infer a type.
throw new PSQLException(GT.tr("Can''t infer the SQL type to use for an instance of {0}. Use setObject() with an explicit Types value to specify the type to use.", x.getClass().getName()), PSQLState.INVALID_PARAMETER_TYPE);
}
}
JDBC và ODBC là hai công nghệ khác nhau và JDBC không quấn quanh ODBC (mặc dù có cầu). – Paolo
@Paolo Tôi biết, tôi đã thiếu một biểu hiện vào thời điểm đó. Tôi đã thay đổi nó cho 'cơ sở dữ liệu' mà là một phù hợp hơn. – SJuan76
Nhưng nếu điều này là tất cả làm thế nào là xác thực đầu vào thực thi? Không đúng cách escapped dây vv? – Jim