@Override public SqlXmlValue newSqlXmlValue(final XmlCharacterStreamProvider provider) { return new AbstractJdbc4SqlXmlValue() { @Override protected void provideXml(SQLXML xmlObject) throws SQLException, IOException { provider.provideXml(xmlObject.setCharacterStream()); } }; }
public SQLXML getSQLXML(int parameterIndex) throws SQLException { try { if (this.wrappedStmt != null) { return ((CallableStatement) this.wrappedStmt).getSQLXML(parameterIndex); } else { throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor); } } catch (SQLException sqlEx) { checkAndFireConnectionError(sqlEx); } return null; }
public SQLXML createSQLXML() throws SQLException { checkClosed(); try { return ((java.sql.Connection) this.mc).createSQLXML(); } catch (SQLException sqlException) { checkAndFireConnectionError(sqlException); } return null; // never reached, but compiler can't tell }
static void setSQLXML(PreparedStatement pstmt, int parameterIndex, SQLXML xmlObject) throws SQLException { if (xmlObject == null) { pstmt.setNull(parameterIndex, Types.SQLXML); } else { // FIXME: Won't work for Non-MYSQL SQLXMLs pstmt.setCharacterStream(parameterIndex, ((JDBC4MysqlSQLXML) xmlObject).serializeAsCharacterStream()); } }
@Override public SqlXmlValue newSqlXmlValue(final Document document) { return new AbstractJdbc4SqlXmlValue() { @Override protected void provideXml(SQLXML xmlObject) throws SQLException, IOException { xmlObject.setResult(DOMResult.class).setNode(document); } }; }
public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { try { if (this.wrappedStmt != null) { ((PreparedStatement) this.wrappedStmt).setSQLXML(parameterIndex, xmlObject); } else { throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor); } } catch (SQLException sqlEx) { checkAndFireConnectionError(sqlEx); } }
public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { try { if (this.wrappedStmt != null) { ((CallableStatement) this.wrappedStmt).setSQLXML(parameterName, xmlObject); } else { throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor); } } catch (SQLException sqlEx) { checkAndFireConnectionError(sqlEx); } }
public SQLXML getSQLXML(String parameterName) throws SQLException { try { if (this.wrappedStmt != null) { return ((CallableStatement) this.wrappedStmt).getSQLXML(parameterName); } else { throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor); } } catch (SQLException sqlEx) { checkAndFireConnectionError(sqlEx); } return null; }
@Override public SQLXML getSQLXML(String columnLabel) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
public SQLXML getSQLXML(String columnLabel) throws SQLException { return getSQLXML(findColumn(columnLabel)); }
@Override default void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { }
@Override public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { throw new SQLFeatureNotSupportedException(); }
@Override public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { parameters.setParameter(parameterIndex, xmlObject); }
/** * Performs validation that the local representation is as up-to-date as the representation on the backing data store. * * @param conn * Connection used for validation. * @param shardMapManager * ShardMapManager reference. * @param shardMap * Shard map for the shard. * @param shard * Shard to validate. */ public static void validateShard(Connection conn, ShardMapManager shardMapManager, StoreShardMap shardMap, StoreShard shard) { Stopwatch stopwatch = Stopwatch.createStarted(); StoreResults lsmResult = new StoreResults(); JAXBElement jaxbElement = StoreOperationRequestBuilder.validateShardLocal(shardMap.getId(), shard.getId(), shard.getVersion()); try (CallableStatement cstmt = conn.prepareCall(String.format("{call %s(?,?)}", StoreOperationRequestBuilder.SP_VALIDATE_SHARD_LOCAL))) { SQLXML sqlxml = conn.createSQLXML(); JAXBContext context = JAXBContext.newInstance(StoreOperationInput.class, StoreShard.class, StoreShardMap.class); // Set the result value from SAX events. SAXResult sxResult = sqlxml.setResult(SAXResult.class); context.createMarshaller().marshal(jaxbElement, sxResult); /* * log.info("Xml:{}\n{}", "ValidateShardLocal", SqlStoreTransactionScope.asString(context, jaxbElement));// */ cstmt.setSQLXML("input", sqlxml); cstmt.registerOutParameter("result", Types.INTEGER); Boolean hasResults = cstmt.execute(); StoreResults storeResults = SqlResults.newInstance(cstmt); // After iterating resultSet's, get result integer. int result = cstmt.getInt("result"); lsmResult.setResult(StoreResult.forValue(result)); stopwatch.stop(); log.info("Shard ValidateShard", "Complete; Shard: {}; Connection: {}; Result: {}; Duration: {}", shard.getLocation(), conn.getMetaData().getURL(), lsmResult.getResult(), stopwatch.elapsed(TimeUnit.MILLISECONDS)); } catch (SQLException | JAXBException e) { e.printStackTrace(); } if (lsmResult.getResult() != StoreResult.Success) { if (lsmResult.getResult() == StoreResult.ShardMapDoesNotExist) { shardMapManager.getCache().deleteShardMap(shardMap); } // Possible errors are: // StoreResult.ShardMapDoesNotExist // StoreResult.ShardDoesNotExist // StoreResult.ShardVersionMismatch // StoreResult.StoreVersionMismatch // StoreResult.MissingParametersForStoredProcedure throw StoreOperationErrorHandler.onValidationErrorLocal(lsmResult, shardMap, shard.getLocation(), "ValidateShard", StoreOperationRequestBuilder.SP_VALIDATE_SHARD_LOCAL); } }
@Test( expected = AlreadyClosedSqlException.class ) public void testClosedResultSet_updateSQLXML2_throws() throws SQLException { closedResultSet.updateSQLXML( "columnLabel", (SQLXML) null ); }
public SQLXML createSQLXML() throws SQLException { return this.getJDBC4Connection().createSQLXML(); }
void setSQLXML(int parameterIndex, SQLXML xmlObject) { parameters.ensureCapacity(parameterIndex+1); }
@Override public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
@Override public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
public SQLXML getSQLXML(int columnIndex) throws SQLException { checkColumnBounds(columnIndex); return new JDBC4MysqlSQLXML(this, columnIndex, getExceptionInterceptor()); }
@Override public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { // TODO Auto-generated method stub throw new UnsupportedOperationException(); }
@Override public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { wrappedResultSet.updateSQLXML( columnIndex, xmlObject ); }
public SQLXML createSQLXML() throws SQLException { return new JDBC4MysqlSQLXML(getExceptionInterceptor()); }
@Override public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { throw SQLError.noSupport(); }
@Override public SQLXML getSQLXML(int parameterIndex) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
@Override public SQLXML getSQLXML(String parameterName) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
@Override public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { checkClosed(); throw SQLError.noSupport(); }
@Override public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
@Override public SQLXML getSQLXML(int columnIndex) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
@Test( expected = AlreadyClosedSqlException.class ) public void testClosedResultSet_updateSQLXML1_throws() throws SQLException { closedResultSet.updateSQLXML( 123, (SQLXML) null ); }
public SQLXML getSQLXML(int columnIndex) throws SQLException { return new JDBC4MysqlSQLXML(this, columnIndex, getExceptionInterceptor()); }
public SQLXML getSQLXML(String columnLabel) throws SQLException { return cacheResultSet.getSQLXML(columnLabel); }
@Override public SQLXML createSQLXML() throws SQLException { return conn.createSQLXML(); }
@Override public Source getXmlAsSource(ResultSet rs, String columnName, Class<? extends Source> sourceClass) throws SQLException { SQLXML xmlObject = rs.getSQLXML(columnName); return (sourceClass != null ? xmlObject.getSource(sourceClass) : xmlObject.getSource(DOMSource.class)); }
@Override public SQLXML getSQLXML() throws SQLException { throw new SQLFeatureNotSupportedException(); }