lishunli / nutz

Automatically exported from code.google.com/p/nutz
0 stars 0 forks source link

DAO使用proxool做数据源会出警告 #132

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
一个简单的插入表例子
首先是 POJO
@Table("user")
public class User {

    @Id
    private int id;
    @Column
    private String username;
    @Column
    private String password;

    public User(){}

    public User(String username, String password) {
        this.username = username;
        this.password = password;
    }
以下省略getter和setter

执行插入代码

public static void main(String[] args) {

        ProxoolDataSource pds = new ProxoolDataSource();

        String alias = "myblog";
        String driver = "com.mysql.jdbc.Driver";
        String url = "jdbc:mysql://localhost/myblog";
        String user = "root";
        String password = "tofishes";
        int maximumConnectionCount = 20;

        pds.setAlias(alias);
        pds.setDriver(driver);
        pds.setDriverUrl(url);
        pds.setUser(user);
        pds.setPassword(password);
        pds.setMaximumConnectionCount(maximumConnectionCount);

        Dao dao = new NutDao(pds);
        User user1 = new User("name", password);
        dao.insert(user1);
}

执行可以成功插入,但是在Eclipse终端会有警告信息打印

2010-3-12 16:52:01 org.logicalcobwebs.proxool.ConnectionPool displayStatistics
信息: Proxool statistics legend: "s - r  (a/t/o)" > s=served, r=refused
(only shown if non-zero), a=active, t=total, o=offline (being tested)
2010-3-12 16:52:01 org.logicalcobwebs.proxool.ProxyConnection
registerClosedStatement
警告: 000003 (01/01/00) - #1 registered a statement as closed which wasn't
known to be open. This could happen if you close a statement twice.
6

如果使用DataSource打开connection,用PreparedStatement执行,没有这�
��的警告。

不晓得是什么原因。

Original issue reported on code.google.com by wendal1985@gmail.com on 12 Mar 2010 at 8:57

GoogleCodeExporter commented 9 years ago
应该检查一下 SqlImpl 是否有关闭两次 Statement 的可能

Original comment by zozoh...@gmail.com on 13 Mar 2010 at 7:32

GoogleCodeExporter commented 9 years ago
执行完 Daos.safeClose(stat, null);
是否应该加上 return

Original comment by wendal1985@gmail.com on 13 Mar 2010 at 7:58

GoogleCodeExporter commented 9 years ago
fix in 1.a.27
fix in r939

原因: Daos.safeClose(stat, null); 
没有检查Statement/ResultSet是否已经关闭,而是直接调
用其close方法.

Original comment by wendal1985@gmail.com on 13 Mar 2010 at 8:46

GoogleCodeExporter commented 9 years ago

Original comment by wendal1985@gmail.com on 15 Mar 2010 at 2:00

GoogleCodeExporter commented 9 years ago
Verified in 1.a.27
Verified by caiceclb

Original comment by wendal1985@gmail.com on 15 Mar 2010 at 2:19

GoogleCodeExporter commented 9 years ago
导致了 Issue 135 :P

Original comment by zozoh...@gmail.com on 16 Mar 2010 at 6:21

GoogleCodeExporter commented 9 years ago
fix in r955

Original comment by zozoh...@gmail.com on 18 Mar 2010 at 2:28

GoogleCodeExporter commented 9 years ago

Original comment by wendal1985@gmail.com on 13 May 2010 at 11:03

GoogleCodeExporter commented 9 years ago
Verified in 1.a.28

Original comment by wendal1985@gmail.com on 15 May 2010 at 8:29