ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.vci.server.base.dbutil;
 
import java.sql.Connection;
 
import com.vci.common.log.ServerWithLog4j;
 
public class DbOperation {
    
    /**
     * get a db connection and a statement
     *
     */
    public DbOperation() {
        
    }
    
    public static Connection getConnect() {
        Connection cnn = null; 
        try {
            cnn  = DBPoolManagement.getConnection();
            if (cnn == null) {
                ServerWithLog4j.logger.warn("--db connet is null!---");
            }
            cnn.setAutoCommit(false);
        } catch (Exception e) {
            e.printStackTrace();
            cnn = null;
        }
        return cnn;
    }
    
    /**
     * release the current connection.
     *
     */
    public static void releaseConnection(Connection cnn) {
        try {
            if (cnn != null) {
                cnn.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if ( cnn != null ) {
                try {
                    cnn.close();
                } catch (Exception e1){
                }
            }
        }
    }
}