/** * If this dictionary supports XML type, * use this method to append xml predicate. * * @param buf the SQL buffer to write the comparison * @param op the comparison operation to perform * @param lhs the left hand side of the comparison * @param rhs the right hand side of the comparison */ public void appendXmlComparison(SQLBuffer buf, String op, FilterValue lhs, FilterValue rhs, boolean lhsxml, boolean rhsxml) { super.appendXmlComparison(buf, op, lhs, rhs, lhsxml, rhsxml); if (lhsxml && rhsxml) appendXmlComparison2(buf, op, lhs, rhs); else if (lhsxml) appendXmlComparison1(buf, op, lhs, rhs); else appendXmlComparison1(buf, op, rhs, lhs); }
/** * Append an xml comparison predicate (both operands map to xml column) * * @param buf the SQL buffer to write the comparison * @param op the comparison operation to perform * @param lhs the left hand side of the comparison (maps to xml column) * @param rhs the right hand side of the comparison (maps to xml column) */ private void appendXmlComparison2(SQLBuffer buf, String op, FilterValue lhs, FilterValue rhs) { appendXmlExtractValue(buf, lhs); buf.append(" ").append(op).append(" "); appendXmlExtractValue(buf, rhs); }
@Override public Object getObject(ResultSet rs, int column, Map map) throws SQLException { // recent oracle drivers return oracle-specific types for timestamps // and dates Object obj = super.getObject(rs, column, map); if (obj == null) return null; if ("oracle.sql.DATE".equals(obj.getClass().getName())) obj = convertFromOracleType(obj, "dateValue"); else if ("oracle.sql.TIMESTAMP".equals(obj.getClass().getName())) obj = convertFromOracleType(obj, "timestampValue"); return obj; }
Select sel) { if (!_checkedUpdateBug) { ensureDriverVendor(); if (forUpdate && _driverBehavior == BEHAVE_DATADIRECT31) log.warn(_loc.get("dd-lock-bug")); if (!isUsingRange(start, end)) { return super.toSelect(select, fetch, tables, where, group, having, order, distinct, forUpdate, 0, Long.MAX_VALUE, sel); if (!requiresSubselectForRange(start, end, distinct, order)) { if (where != null && !where.isEmpty()) buf.append(where).append(" AND "); if (!isUsingOffset(start)) { buf.append(getSelectOperation(fetch) + " * FROM ("); buf.append(newsel); buf.append(") WHERE ROWNUM <= ").appendValue(end); buf.append(getSelectOperation(fetch)) .append(" * FROM (SELECT r.*, ROWNUM RNUM FROM ("); buf.append(newsel); buf.append(") r"); if (isUsingLimit(end)) buf.append(" WHERE ROWNUM <= ").appendValue(end); buf.append(") WHERE RNUM > ").appendValue(start);
@Override public void setNull(PreparedStatement stmnt, int idx, int colType, Column col) throws SQLException { if ((colType == Types.CLOB || colType == Types.BLOB) && col.isNotNull()) throw new UserException(_loc.get("null-blob-in-not-nullable", toDBName(col .getFullDBIdentifier()))); if (colType == Types.BLOB && _driverBehavior == BEHAVE_ORACLE) stmnt.setBlob(idx, getEmptyBlob()); else if (colType == Types.CLOB && _driverBehavior == BEHAVE_ORACLE && !col.isXML()) stmnt.setClob(idx, getEmptyClob()); else if ((colType == Types.STRUCT || colType == Types.OTHER) && col != null && !DBIdentifier.isNull(col.getTypeIdentifier())) stmnt.setNull(idx, Types.STRUCT, col.getTypeIdentifier().getName()); // some versions of the Oracle JDBC driver will fail if calling // setNull with DATE; see bug #1171 else if (colType == Types.DATE) super.setNull(stmnt, idx, Types.TIMESTAMP, col); // the Oracle driver does not support Types.OTHER with setNull else if (colType == Types.OTHER || col.isXML()) super.setNull(stmnt, idx, Types.NULL, col); else super.setNull(stmnt, idx, colType, col); }
/** * Ensure that the driver vendor has been set, and if not, set it now. */ public void ensureDriverVendor() { if (driverVendor != null) { cacheDriverBehavior(driverVendor); return; } if (log.isInfoEnabled()) log.info(_loc.get("oracle-connecting-for-driver")); Connection conn = null; try { conn = conf.getDataSource2(null).getConnection(); connectedConfiguration(conn); } catch (SQLException se) { throw SQLExceptions.getStore(se, this); } finally { if (conn != null) try { conn.close(); } catch (SQLException se) { } } }
Select sel) { if (!_checkedUpdateBug) { ensureDriverVendor(); if (forUpdate && _driverBehavior == BEHAVE_DATADIRECT31) log.warn(_loc.get("dd-lock-bug")); if (!requiresSubselectForRange(start, end, distinct, order)) { if (where != null && !where.isEmpty()) buf.append(where).append(" AND "); buf.append(getSelectOperation(fetch) + " * FROM ("); buf.append(newsel); buf.append(") WHERE ROWNUM <= ").appendValue(end); buf.append(getSelectOperation(fetch) + " * FROM (SELECT r.*, ROWNUM RNUM FROM ("); buf.append(newsel);
} else { setCharacterStream(stmnt, idx, new StringReader(val), val.length(), col); stmnt.setClob(idx, getEmptyClob()); else { super.setClobString(stmnt, idx, val, col);
driverVendor = VENDOR_OTHER; cacheDriverBehavior(driverVendor); guessJDBCVersion(conn);
@Override public void setBinaryStream(PreparedStatement stmnt, int idx, InputStream val, int length, Column col) throws SQLException { if (length == 0) stmnt.setBlob(idx, getEmptyBlob()); else { super.setBinaryStream(stmnt, idx, val, length, col); } }
public void setNull(PreparedStatement stmnt, int idx, int colType, Column col) throws SQLException { if (colType == Types.BLOB && _driverBehavior == BEHAVE_ORACLE) stmnt.setBlob(idx, getEmptyBlob()); else if (colType == Types.CLOB && _driverBehavior == BEHAVE_ORACLE && !col.isXML()) stmnt.setClob(idx, getEmptyClob()); else if ((colType == Types.STRUCT || colType == Types.OTHER) && col != null && col.getTypeName() != null) stmnt.setNull(idx, Types.STRUCT, col.getTypeName()); // some versions of the Oracle JDBC driver will fail if calling // setNull with DATE; see bug #1171 else if (colType == Types.DATE) super.setNull(stmnt, idx, Types.TIMESTAMP, col); // the Oracle driver does not support Types.OTHER with setNull else if (colType == Types.OTHER || col.isXML()) super.setNull(stmnt, idx, Types.NULL, col); else super.setNull(stmnt, idx, colType, col); }
public String getClobString(ResultSet rs, int column) throws SQLException { if (_driverBehavior != BEHAVE_ORACLE) return super.getClobString(rs, column); Clob clob = getClob(rs, column); if (clob == null) return null; if (clob.getClass().getName().equals("oracle.sql.CLOB")) { try { if (((Boolean) Class.forName("oracle.sql.CLOB"). getMethod("isEmptyLob", new Class[0]). invoke(clob, new Object[0])). booleanValue()) return null; } catch (Exception e) { // possibly different version of the driver } } if (clob.length() == 0) return null; // unlikely that we'll have strings over 4 billion chars return clob.getSubString(1, (int) clob.length()); }
public void insertClobForStreamingLoad(Row row, Column col, Object ob) throws SQLException { if (ob == null) { col.setType(Types.OTHER); row.setNull(col); } else { row.setClob(col, getEmptyClob()); } }
driverVendor = VENDOR_OTHER; cacheDriverBehavior(driverVendor);
Select sel) { if (!_checkedUpdateBug) { ensureDriverVendor(); if (forUpdate && _driverBehavior == BEHAVE_DATADIRECT31) log.warn(_loc.get("dd-lock-bug")); if (!isUsingRange(start, end)) { return super.toSelect(select, fetch, tables, where, group, having, order, distinct, forUpdate, 0, Long.MAX_VALUE, sel); if (!requiresSubselectForRange(start, end, distinct, order)) { if (where != null && !where.isEmpty()) buf.append(where).append(" AND "); if (!isUsingOffset(start)) { buf.append(getSelectOperation(fetch) + " * FROM ("); buf.append(newsel); buf.append(") WHERE ROWNUM <= ").appendValue(end); buf.append(getSelectOperation(fetch)) .append(" * FROM (SELECT r.*, ROWNUM RNUM FROM ("); buf.append(newsel); buf.append(") r"); if (isUsingLimit(end)) buf.append(" WHERE ROWNUM <= ").appendValue(end); buf.append(") WHERE RNUM > ").appendValue(start);
@Override public void setNull(PreparedStatement stmnt, int idx, int colType, Column col) throws SQLException { if ((colType == Types.CLOB || colType == Types.BLOB) && col.isNotNull()) throw new UserException(_loc.get("null-blob-in-not-nullable", toDBName(col .getFullDBIdentifier()))); if (colType == Types.BLOB && _driverBehavior == BEHAVE_ORACLE) stmnt.setBlob(idx, getEmptyBlob()); else if (colType == Types.CLOB && _driverBehavior == BEHAVE_ORACLE && !col.isXML()) stmnt.setClob(idx, getEmptyClob()); else if ((colType == Types.STRUCT || colType == Types.OTHER) && col != null && !DBIdentifier.isNull(col.getTypeIdentifier())) stmnt.setNull(idx, Types.STRUCT, col.getTypeIdentifier().getName()); // some versions of the Oracle JDBC driver will fail if calling // setNull with DATE; see bug #1171 else if (colType == Types.DATE) super.setNull(stmnt, idx, Types.TIMESTAMP, col); // the Oracle driver does not support Types.OTHER with setNull else if (colType == Types.OTHER || col.isXML()) super.setNull(stmnt, idx, Types.NULL, col); else super.setNull(stmnt, idx, colType, col); }
/** * Ensure that the driver vendor has been set, and if not, set it now. */ public void ensureDriverVendor() { if (driverVendor != null) { cacheDriverBehavior(driverVendor); return; } if (log.isInfoEnabled()) log.info(_loc.get("oracle-connecting-for-driver")); Connection conn = null; try { conn = conf.getDataSource2(null).getConnection(); connectedConfiguration(conn); } catch (SQLException se) { throw SQLExceptions.getStore(se, this); } finally { if (conn != null) try { conn.close(); } catch (SQLException se) { } } }
} else { setCharacterStream(stmnt, idx, new StringReader(val), val.length(), col); stmnt.setClob(idx, getEmptyClob()); else { super.setClobString(stmnt, idx, val, col);
driverVendor = VENDOR_OTHER; cacheDriverBehavior(driverVendor); guessJDBCVersion(conn);
@Override public void setBinaryStream(PreparedStatement stmnt, int idx, InputStream val, int length, Column col) throws SQLException { if (length == 0) stmnt.setBlob(idx, getEmptyBlob()); else { super.setBinaryStream(stmnt, idx, val, length, col); } }