@Override public Clob createClob(String string) { try { final Clob clob = createClob(); clob.setString( 1, string ); return clob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set CLOB string after creation", e ); } }
@Override public NClob createNClob(String string) { try { final NClob nclob = createNClob(); nclob.setString( 1, string ); return nclob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set NCLOB string after creation", e ); } }
@Override public Blob createBlob(byte[] bytes) { try { final Blob blob = createBlob(); blob.setBytes( 1, bytes ); return blob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set BLOB bytes after creation", e ); } }
private void create(boolean script, boolean export, Writer fileOutput, Statement statement) throws IOException { for ( int j = 0; j < createSQL.length; j++ ) { try { execute( script, export, fileOutput, statement, createSQL[j] ); } catch ( SQLException e ) { if ( haltOnError ) { throw new JDBCException( "Error during DDL export", e ); } exceptions.add( e ); log.error( "Unsuccessful: " + createSQL[j] ); log.error( e.getMessage() ); } } }
@Override public Blob createBlob(byte[] bytes) { try { final Blob blob = createBlob(); blob.setBytes( 1, bytes ); return blob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set BLOB bytes after creation", e ); } }
@Override public NClob createNClob(String string) { try { final NClob nclob = createNClob(); nclob.setString( 1, string ); return nclob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set NCLOB string after creation", e ); } }
/** * {@inheritDoc} */ public Blob createBlob(byte[] bytes) { try { Blob blob = createBlob(); blob.setBytes( 1, bytes ); return blob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set BLOB bytes after creation", e ); } }
/** * {@inheritDoc} */ public NClob createNClob(String string) { try { NClob nclob = createNClob(); nclob.setString( 1, string ); return nclob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set NCLOB string after creation", e ); } }
/** * {@inheritDoc} */ public NClob createNClob(String string) { try { NClob nclob = createNClob(); nclob.setString( 1, string ); return nclob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set NCLOB string after creation", e ); } }
/** * {@inheritDoc} */ public Blob createBlob(byte[] bytes) { try { Blob blob = createBlob(); blob.setBytes( 1, bytes ); return blob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set BLOB bytes after creation", e ); } }
@Override public Clob createClob(String string) { try { final Clob clob = createClob(); clob.setString( 1, string ); return clob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set CLOB string after creation", e ); } }
/** * {@inheritDoc} */ public Clob createClob(String string) { try { Clob clob = createClob(); clob.setString( 1, string ); return clob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set CLOB string after creation", e ); } }
/** * {@inheritDoc} */ public Clob createClob(String string) { try { Clob clob = createClob(); clob.setString( 1, string ); return clob; } catch ( SQLException e ) { throw new JDBCException( "Unable to set CLOB string after creation", e ); } }
/** * {@inheritDoc} */ public Blob createBlob(InputStream inputStream, long length) { try { Blob blob = createBlob(); OutputStream byteStream = blob.setBinaryStream( 1 ); StreamUtils.copy( inputStream, byteStream ); byteStream.flush(); byteStream.close(); // todo : validate length written versus length given? return blob; } catch ( SQLException e ) { throw new JDBCException( "Unable to prepare BLOB binary stream for writing",e ); } catch ( IOException e ) { throw new HibernateException( "Unable to write stream contents to BLOB", e ); } }
/** * {@inheritDoc} */ public Clob createClob(Reader reader, long length) { try { Clob clob = createClob(); Writer writer = clob.setCharacterStream( 1 ); StreamUtils.copy( reader, writer ); writer.flush(); writer.close(); return clob; } catch ( SQLException e ) { throw new JDBCException( "Unable to prepare CLOB stream for writing", e ); } catch ( IOException e ) { throw new HibernateException( "Unable to write CLOB stream content", e ); } }
/** * {@inheritDoc} */ public Clob createClob(Reader reader, long length) { try { Clob clob = createClob(); Writer writer = clob.setCharacterStream( 1 ); StreamUtils.copy( reader, writer ); writer.flush(); writer.close(); return clob; } catch ( SQLException e ) { throw new JDBCException( "Unable to prepare CLOB stream for writing", e ); } catch ( IOException e ) { throw new HibernateException( "Unable to write CLOB stream content", e ); } }
/** * {@inheritDoc} */ public NClob createNClob(Reader reader, long length) { try { NClob nclob = createNClob(); Writer writer = nclob.setCharacterStream( 1 ); StreamUtils.copy( reader, writer ); writer.flush(); writer.close(); return nclob; } catch ( SQLException e ) { throw new JDBCException( "Unable to prepare NCLOB stream for writing", e ); } catch ( IOException e ) { throw new HibernateException( "Unable to write NCLOB stream content", e ); } }
/** * {@inheritDoc} */ public NClob createNClob(Reader reader, long length) { try { NClob nclob = createNClob(); Writer writer = nclob.setCharacterStream( 1 ); StreamUtils.copy( reader, writer ); writer.flush(); writer.close(); return nclob; } catch ( SQLException e ) { throw new JDBCException( "Unable to prepare NCLOB stream for writing", e ); } catch ( IOException e ) { throw new HibernateException( "Unable to write NCLOB stream content", e ); } }
/** * {@inheritDoc} */ public Blob createBlob(InputStream inputStream, long length) { try { Blob blob = createBlob(); OutputStream byteStream = blob.setBinaryStream( 1 ); StreamUtils.copy( inputStream, byteStream ); byteStream.flush(); byteStream.close(); // todo : validate length written versus length given? return blob; } catch ( SQLException e ) { throw new JDBCException( "Unable to prepare BLOB binary stream for writing",e ); } catch ( IOException e ) { throw new HibernateException( "Unable to write stream contents to BLOB", e ); } }
public void apply(Object target, WireContext wireContext) { Configuration configuration = (Configuration) target; Properties cfgProperties = configuration.getProperties(); Dialect dialect = Dialect.getDialect(cfgProperties); ConnectionProvider connectionProvider = ConnectionProviderFactory .newConnectionProvider(cfgProperties); try { Connection connection = connectionProvider.getConnection(); try { DatabaseMetadata metadata = new DatabaseMetadata(connection, dialect); String[] updateScript = configuration.generateSchemaUpdateScript( dialect, metadata); LOG.debug("updating db schema"); executeScript(connection, updateScript); } finally { connectionProvider.closeConnection(connection); } } catch (SQLException e) { throw new JDBCException("error updating schema", e); } finally { connectionProvider.close(); } }