Example usage for org.hibernate JDBCException getErrorCode

List of usage examples for org.hibernate JDBCException getErrorCode

Introduction

In this page you can find the example usage for org.hibernate JDBCException getErrorCode.

Prototype

public int getErrorCode() 

Source Link

Document

Get the vendor specific error code from the underlying SQLException .

Usage

From source file:vn.edu.vnu.uet.fit.beans.GenericBean.java

public void create() {
    try {/* ww  w.j  av a  2s.  com*/
        getModel().create(obj);
        JSFUtil.addSuccessMessage(null, "Insert success", "Insert success: " + getEntityMsg(obj));
        RequestContext.getCurrentInstance().execute("PF('wgCreate').hide()");
        lst = null;
    } catch (JDBCException ex) {
        System.out.println("=== ERROR CODE: " + ex.getErrorCode());
        JSFUtil.addErrorMessage(null, "SQL Error", "Insert error code: " + ex.getErrorCode());
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("=== ERROR: " + ex.getMessage());
        JSFUtil.addErrorMessage(null, "Error", ex.getMessage());
    }
}

From source file:vn.edu.vnu.uet.fit.beans.UsersBean.java

public void create() {
    try {// ww  w  . java2s . c  o m
        System.out.println("CREATE USER: " + createdUser);
        model.create(createdUser);
        JSFUtil.addSuccessMessage("frm:msg", "Insert success",
                "Insert success account " + createdUser.getUsername());
        RequestContext.getCurrentInstance().execute("PF('wgCreate').hide()");
        lst = null;
    } catch (JDBCException ex) {
        System.out.println("=== ERROR CODE: " + ex.getErrorCode());
        JSFUtil.addErrorMessage(null, "SQL Error", "Insert error code: " + ex.getErrorCode());
    } catch (Exception ex) {
        System.out.println("=== ERROR: " + ex.getMessage());
        JSFUtil.addErrorMessage(null, "Error", ex.getMessage());
    }
}