Java Code Examples for org.springframework.jdbc.support.lob.LobCreator#close()

The following examples show how to use org.springframework.jdbc.support.lob.LobCreator#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractLobCreatingPreparedStatementCallback.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public final Integer doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
	LobCreator lobCreator = this.lobHandler.getLobCreator();
	try {
		setValues(ps, lobCreator);
		return ps.executeUpdate();
	}
	finally {
		lobCreator.close();
	}
}
 
Example 2
Source File: AbstractLobCreatingPreparedStatementCallback.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public final Integer doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
	LobCreator lobCreator = this.lobHandler.getLobCreator();
	try {
		setValues(ps, lobCreator);
		return ps.executeUpdate();
	}
	finally {
		lobCreator.close();
	}
}
 
Example 3
Source File: RecordLoader.java    From DataLink with Apache License 2.0 5 votes vote down vote up
private LoadResult loadInSingle(TaskWriterContext context, List<T> records, DbDialect dbDialect) {
    //statistic before
    LoadResult loadResult = new LoadResult();
    long startTime = System.currentTimeMillis();

    //do load
    LobCreator lobCreator = dbDialect.getLobHandler().getLobCreator();
    try {
        for (T record : records) {
            try {
                dbDialect.getTransactionTemplate().execute(transactionStatus -> {
                    transactionBegin();
                    JdbcTemplate template = dbDialect.getJdbcTemplate();
                    int i = loadOne(context, record, dbDialect, lobCreator, template);
                    transactionEnd();
                    return 0;
                });
            } catch (Throwable e) {
                if (e instanceof DuplicateKeyException) {
                    logger.warn("DuplicateKeyException for record load :" + e.getMessage());
                } else {
                    throw new RecordLoadException(record, e);
                }
            }
        }
    } finally {
        lobCreator.close();
    }

    //statistic after
    long totalTime = System.currentTimeMillis() - startTime;
    loadResult.setTotalRecords(records.size());
    loadResult.setTotalSqlTime(totalTime);
    loadResult.setAvgSqlTime(totalTime / records.size());

    return loadResult;
}
 
Example 4
Source File: AbstractLobCreatingPreparedStatementCallback.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final Integer doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
	LobCreator lobCreator = this.lobHandler.getLobCreator();
	try {
		setValues(ps, lobCreator);
		return ps.executeUpdate();
	}
	finally {
		lobCreator.close();
	}
}
 
Example 5
Source File: AbstractLobCreatingPreparedStatementCallback.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public final Integer doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
	LobCreator lobCreator = this.lobHandler.getLobCreator();
	try {
		setValues(ps, lobCreator);
		return ps.executeUpdate();
	}
	finally {
		lobCreator.close();
	}
}
 
Example 6
Source File: AbstractLobCreatingPreparedStatementCallback.java    From effectivejava with Apache License 2.0 5 votes vote down vote up
@Override
public final Integer doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
	LobCreator lobCreator = this.lobHandler.getLobCreator();
	try {
		setValues(ps, lobCreator);
		return ps.executeUpdate();
	}
	finally {
		lobCreator.close();
	}
}