@SuppressWarnings("deprecation") private SqlExceptionHelper buildSqlExceptionHelper(Dialect dialect, boolean logWarnings) { final StandardSQLExceptionConverter sqlExceptionConverter = new StandardSQLExceptionConverter(); sqlExceptionConverter.addDelegate( dialect.buildSQLExceptionConversionDelegate() ); sqlExceptionConverter.addDelegate( new SQLExceptionTypeDelegate( dialect ) ); // todo : vary this based on extractedMetaDataSupport.getSqlStateType() sqlExceptionConverter.addDelegate( new SQLStateConversionDelegate( dialect ) ); return new SqlExceptionHelper( sqlExceptionConverter, logWarnings ); }
public void release() throws SQLException { new SqlExceptionHelper().logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } connection = null; } }
public void release() throws SQLException { new SqlExceptionHelper().logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } connection = null; } }
public static PersistenceException toV5HibernateException(final SQLException ex, final String message) { return new SqlExceptionHelper(true).convert(ex, message); }
public void release() throws SQLException { // we only release the connection if ( connection != null ) { new SqlExceptionHelper().logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } provider.closeConnection( connection ); connection = null; } } }
public void release() throws SQLException { // we only release the connection if ( connection != null ) { new SqlExceptionHelper().logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } provider.closeConnection( connection ); connection = null; } } }
@Override public void release() throws SQLException { // we only release the connection if ( connection != null ) { new SqlExceptionHelper().logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } provider.closeConnection( connection ); connection = null; } } }
public SchemaExport( ConnectionHelper connectionHelper, String[] dropSql, String[] createSql) { this.connectionHelper = connectionHelper; this.dropSQL = dropSql; this.createSQL = createSql; this.importFiles = ""; this.sqlStatementLogger = new SqlStatementLogger( false, true ); this.sqlExceptionHelper = new SqlExceptionHelper(); this.formatter = FormatStyle.DDL.getFormatter(); }
public SchemaExport( ConnectionHelper connectionHelper, String[] dropSql, String[] createSql) { this.connectionHelper = connectionHelper; this.dropSQL = dropSql; this.createSQL = createSql; this.importFiles = ""; this.sqlStatementLogger = new SqlStatementLogger( false, true ); this.sqlExceptionHelper = new SqlExceptionHelper(); this.formatter = FormatStyle.DDL.getFormatter(); }
public SchemaUpdate(Configuration configuration, Properties properties) throws HibernateException { this.configuration = configuration; this.dialect = Dialect.getDialect( properties ); Properties props = new Properties(); props.putAll( dialect.getDefaultProperties() ); props.putAll( properties ); this.connectionHelper = new ManagedProviderConnectionHelper( props ); this.sqlExceptionHelper = new SqlExceptionHelper(); this.sqlStatementLogger = new SqlStatementLogger( false, true ); this.formatter = FormatStyle.DDL.getFormatter(); }
public SchemaUpdate(Configuration configuration, Properties properties) throws HibernateException { this.configuration = configuration; this.dialect = Dialect.getDialect( properties ); Properties props = new Properties(); props.putAll( dialect.getDefaultProperties() ); props.putAll( properties ); this.connectionHelper = new ManagedProviderConnectionHelper( props ); this.sqlExceptionHelper = new SqlExceptionHelper(); this.sqlStatementLogger = new SqlStatementLogger( false, true ); this.formatter = FormatStyle.DDL.getFormatter(); }
private void releaseConnection() throws SQLException { if (connection != null) { try { new SqlExceptionHelper().logAndClearWarnings(connection); } finally { try { serviceRegistry.getService(ConnectionProvider.class).closeConnection(connection); } finally { connection = null; } } } }
private void releaseConnection() throws SQLException { if ( connection != null ) { try { new SqlExceptionHelper().logAndClearWarnings( connection ); } finally { try { serviceRegistry.getService( ConnectionProvider.class ).closeConnection( connection ); } finally { connection = null; } } } }
private void releaseConnection() throws SQLException { if ( connection != null ) { try { new SqlExceptionHelper().logAndClearWarnings( connection ); } finally { try { serviceRegistry.getService( ConnectionProvider.class ).closeConnection( connection ); } finally { connection = null; } } } }
private void execute(boolean script, boolean export, Writer fileOutput, Statement statement, final String sql) throws IOException, SQLException { final SqlExceptionHelper sqlExceptionHelper = new SqlExceptionHelper(); String formatted = formatter.format( sql ); if (delimiter != null) formatted += delimiter; if (script) System.out.println(formatted); LOG.debug(formatted); if ( outputFile != null ) { fileOutput.write( formatted + "\n" ); } if ( export ) { statement.executeUpdate( sql ); try { SQLWarning warnings = statement.getWarnings(); if ( warnings != null) { sqlExceptionHelper.logAndClearWarnings( connectionHelper.getConnection() ); } } catch( SQLException sqle ) { LOG.unableToLogSqlWarnings(sqle); } } }
@SuppressWarnings("deprecation") private SqlExceptionHelper buildSqlExceptionHelper(Dialect dialect, boolean logWarnings) { final StandardSQLExceptionConverter sqlExceptionConverter = new StandardSQLExceptionConverter(); sqlExceptionConverter.addDelegate( dialect.buildSQLExceptionConversionDelegate() ); sqlExceptionConverter.addDelegate( new SQLExceptionTypeDelegate( dialect ) ); // todo : vary this based on extractedMetaDataSupport.getSqlStateType() sqlExceptionConverter.addDelegate( new SQLStateConversionDelegate( dialect ) ); return new SqlExceptionHelper( sqlExceptionConverter, logWarnings ); }
public SchemaUpdate(ServiceRegistry serviceRegistry, Configuration cfg) throws HibernateException { this.configuration = cfg; final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); this.dialect = jdbcServices.getDialect(); this.connectionHelper = new SuppliedConnectionProviderConnectionHelper( jdbcServices.getConnectionProvider() ); this.sqlExceptionHelper = new SqlExceptionHelper(); this.sqlStatementLogger = jdbcServices.getSqlStatementLogger(); this.formatter = ( sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter(); }
public SchemaUpdate(ServiceRegistry serviceRegistry, Configuration cfg) throws HibernateException { this.configuration = cfg; final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); this.dialect = jdbcServices.getDialect(); this.connectionHelper = new SuppliedConnectionProviderConnectionHelper( jdbcServices.getConnectionProvider() ); this.sqlExceptionHelper = new SqlExceptionHelper(); this.sqlStatementLogger = jdbcServices.getSqlStatementLogger(); this.formatter = ( sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter(); }
/** * Create a schema exporter for the given Configuration, using the supplied connection for connectivity. * * @param configuration The configuration to use. * @param connection The JDBC connection to use. * @throws HibernateException Indicates problem preparing for schema export. */ public SchemaExport(Configuration configuration, Connection connection) throws HibernateException { this.connectionHelper = new SuppliedConnectionHelper( connection ); this.sqlStatementLogger = new SqlStatementLogger( false, true ); this.formatter = FormatStyle.DDL.getFormatter(); this.sqlExceptionHelper = new SqlExceptionHelper(); this.importFiles = ConfigurationHelper.getString( AvailableSettings.HBM2DDL_IMPORT_FILES, configuration.getProperties(), DEFAULT_IMPORT_FILE ); final Dialect dialect = Dialect.getDialect( configuration.getProperties() ); this.dropSQL = configuration.generateDropSchemaScript( dialect ); this.createSQL = configuration.generateSchemaCreationScript( dialect ); }
/** * Create a schema exporter for the given Configuration, using the supplied connection for connectivity. * * @param configuration The configuration to use. * @param connection The JDBC connection to use. * @throws HibernateException Indicates problem preparing for schema export. */ public SchemaExport(Configuration configuration, Connection connection) throws HibernateException { this.connectionHelper = new SuppliedConnectionHelper( connection ); this.sqlStatementLogger = new SqlStatementLogger( false, true ); this.formatter = FormatStyle.DDL.getFormatter(); this.sqlExceptionHelper = new SqlExceptionHelper(); this.importFiles = ConfigurationHelper.getString( AvailableSettings.HBM2DDL_IMPORT_FILES, configuration.getProperties(), DEFAULT_IMPORT_FILE ); final Dialect dialect = Dialect.getDialect( configuration.getProperties() ); this.dropSQL = configuration.generateDropSchemaScript( dialect ); this.createSQL = configuration.generateSchemaCreationScript( dialect ); }