whyclxw
2021-05-13 366b7c2daeac609853befcc05ddbac2058425c52
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
package com.sql;
import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;
 
import com.mchange.v2.c3p0.ComboPooledDataSource;
 
 
public class SybaseConnPool {
private ComboPooledDataSource sybase_ds = new ComboPooledDataSource();
    
    public SybaseConnPool()
    {
        try {
            init();
        } catch (PropertyVetoException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    public void init() throws PropertyVetoException
    {
        sybase_ds.setDriverClass("com.sybase.jdbc3.jdbc.SybDriver");
        /*
        String connStr = "jdbc:sybase:Tds:" + GetIpAddr.getLoacalHostIp() 
                        + ":5000/battdata?language=us_english&charset=cp936";
        sybase_ds.setJdbcUrl(connStr);
        */
        //sybase_ds.setJdbcUrl("jdbc:sybase:Tds:192.168.2.104:5000/battdata?language=us_english&charset=cp936");
        sybase_ds.setJdbcUrl("jdbc:sybase:Tds:192.168.48.129:5000/battdata?language=us_english&charset=cp936");
        sybase_ds.setUser("sa");
        sybase_ds.setPassword("");
        sybase_ds.setMaxPoolSize(3);
        sybase_ds.setMinPoolSize(1);
    }
    public Connection getConn()
    {
        Connection con = null;
        try {
            con = sybase_ds.getConnection();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return con;
    }
}