GenericJDBCException:无法打开连接**性能指标报告**

时间:2015-07-01 17:36:54

标签: java swing hibernate swingworker

我有以下

javax.swing.Timer timer = new javax.swing.Timer(3000, new java.awt.event.ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        jLabelMsgL.setText("");
        NitgenSwingWorker sWorker = new NitgenSwingWorker();
        sWorker.execute();
    }
});
timer.start();

private final class NitgenSwingWorker extends SwingWorker<Boolean, Void> {
    @Override
    protected Boolean doInBackground() throws Exception {
        return nitgen.checkFinger();
    }

    @Override
    protected void done() {
        try {
            Boolean isCheckFinger = get();
            if(isCheckFinger){
                delegate.getListaByIdEmpleado(123);
            }else{
                delegate.getListaByIdEmpleado(123);
            }
        } catch (InterruptedException | ExecutionException e) {
            System.err.println("NitgenSwingWorker Error: " + e.getMessage());
        }
    }
}

但当&#39; isCheckFinger&#39;是的,抛出

Mon Jun 29 10:44:14 CDT 2015 INFO: ** Performance Metrics Report **

Longest reported query: 0 ms
Shortest reported query: 9223372036854775807 ms
Average query execution time: NaN ms
Number of statements executed: 0
Number of result sets created: 0
Number of statements prepared: 0
Number of prepared statement executions: 0
Mon Jun 29 10:44:14 CDT 2015 TRACE: send() packet payload:
0a 00 00 00 03 73 65 6c     . . . . . s e l 
65 63 74 20 31 3b           e c t . 1 ; 

org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
...

Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
    at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)
...

Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
    at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
    at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
...

当nitgen.checkFinger返回true时,只发送错误, nitgen是指纹识别器的库。我想当这回归 是的,它在swing中改变了一些东西并且无法访问hibernate。 发送异常直到它尝试执行此操作:

getSession().beginTransaction()

否则没有问题,任何人都可以帮助我?

1 个答案:

答案 0 :(得分:0)

我解决了 问题是我使用的是JNI库,当值发生变化时,就会发生这种情况。修复并更改默认值并准备好解决。

public boolean checkFinger() throws Exception {
    //Boolean thereIsFinger = Boolean.FALSE; //original line
    Boolean thereIsFinger = Boolean.TRUE;   //solution
    //bsp is a JNI Library 
    bsp.CheckFinger(thereIsFinger);
    return thereIsFinger;
}