Example usage for org.hibernate.engine.jdbc NonContextualLobCreator INSTANCE

List of usage examples for org.hibernate.engine.jdbc NonContextualLobCreator INSTANCE

Introduction

In this page you can find the example usage for org.hibernate.engine.jdbc NonContextualLobCreator INSTANCE.

Prototype

NonContextualLobCreator INSTANCE

To view the source code for org.hibernate.engine.jdbc NonContextualLobCreator INSTANCE.

Click Source Link

Document

Singleton access

Usage

From source file:org.snaker.jfinal.access.JfinalAccess.java

License:Apache License

/**
 * JDBC?BLOB/* ww  w .  j  a  v  a  2 s.c om*/
 */
@Override
public void saveProcess(Process process) {
    super.saveProcess(process);
    if (process.getBytes() != null) {
        Connection conn = null;
        PreparedStatement pstmt = null;
        try {
            conn = getConnection();
            pstmt = conn.prepareStatement(PROCESS_UPDATE_BLOB);
            //            pstmt.setBytes(1,process.getBytes());
            process.setContent(NonContextualLobCreator.INSTANCE
                    .wrap(NonContextualLobCreator.INSTANCE.createBlob(process.getBytes())));
            pstmt.setBlob(1, process.getContent());
            pstmt.setString(2, process.getId());
            pstmt.execute();
        } catch (Exception e) {
            throw new SnakerException(e.getMessage(), e.getCause());
        } finally {
            try {
                JdbcHelper.close(pstmt);
            } catch (SQLException e) {
                throw new SnakerException(e.getMessage(), e.getCause());
            }
        }
    }
}

From source file:org.snaker.jfinal.access.JfinalAccess.java

License:Apache License

/**
 * JDBC?BLOB// w  w w  . jav a 2  s. c  o  m
 */
@Override
public void updateProcess(Process process) {
    super.updateProcess(process);
    if (process.getBytes() != null) {
        Connection conn = null;
        PreparedStatement pstmt = null;
        try {
            conn = getConnection();
            pstmt = conn.prepareStatement(PROCESS_UPDATE_BLOB);
            //            pstmt.setBytes(1, process.getBytes());//blob//postgresql
            process.setContent(NonContextualLobCreator.INSTANCE
                    .wrap(NonContextualLobCreator.INSTANCE.createBlob(process.getBytes())));
            pstmt.setBlob(1, process.getContent());
            pstmt.setString(2, process.getId());
            pstmt.execute();
        } catch (Exception e) {
            throw new SnakerException(e.getMessage(), e.getCause());
        } finally {
            try {
                JdbcHelper.close(pstmt);
            } catch (SQLException e) {
                throw new SnakerException(e.getMessage(), e.getCause());
            }
        }
    }
}