jdbc2.0 应该用 DataSource 啦!

解决方案 »

  1.   

    jdbc2 option pack 中的ConnectionPoolDateSource和PooledConnection的用法谁知道,最好贴一点例程上来。DataSource又不牵涉连接池,和DriverManager有什么区别?这里的java程序员好象没有几个是做过真正数据库开发的。
      

  2.   

    有一本红皮的SELVERT书讲了这个问题,我只看了一点,没用过连接池
      

  3.   

    ====================== From http://java.sun.com/j2se/1.3/docs/api/java/sql/DriverManager.htmlThe basic service for managing a set of JDBC drivers.
    NOTE: The DataSource interface, new in the JDBC 2.0 API, provides another way to connect to a data source. The use of a DataSource object is the preferred means of connecting to a data source. As part of its initialization, the DriverManager class will attempt to load the driver classes referenced in the "jdbc.drivers" system property. This allows a user to customize the JDBC Drivers used by their applications. For example in your ~/.hotjava/properties file you might specify:  jdbc.drivers=foo.bah.Driver:wombat.sql.Driver:bad.taste.ourDriver
     
    A program can also explicitly load JDBC drivers at any time. For example, the my.sql.Driver is loaded with the following statement: 
     Class.forName("my.sql.Driver");
     
    When the method getConnection is called, the DriverManager will attempt to locate a suitable driver from amongst those loaded at initialization and those loaded explicitly using the same classloader as the current applet or application. Starting with the Java 2 SDK, Standard Edition, version 1.3, a logging stream can be set only if the proper permission has been granted. Normally this will be done with the tool PolicyTool, which can be used to grant permission java.sql.SQLPermission "setLog". 
    ==================================================================ConnectionPool通常不需要自己实现,因为机制比较简单,而且只适合用于dbconnection,然后应用服务器都有,一般都可以通过给个application connection pool的url或者check out等方式获得。如果你有自己的一些特殊需求当然不同,比如在每个联接打开的时候作些什么操作等等。ConnectionPool跟其他的javaapi方式都是类似的,外部调用基于那几个getconnection之流的event/listener架构,内部负责初始化、联接建立、断掉联接、联接获取、回收联接、回滚提交、动态增长减少、超时控制、日志管理等,而且现在大家越来越喜欢将这些杂七杂八的东西摆到jndi里面去读取了。Informix i.Sell中联接的方式就可以通过几种办法实现,基于的原理就是datastore中存储connection,然后通过一个无需附带服务器ip、口令等信息的
    url或者直接调用checkout方法来获取,并且其他的连接诸如socket等也可以集成到这种管理机制里面。你也可以在自己的项目里面借鉴这种用法,将一些昂贵的资源pool一把。:)
    mail: [email protected]
      

  4.   

    唉,什么时候咱们国家也来个什么大型数据库,大家也来讨论一把如何编写jdbc driver。:)
      

  5.   

    问下各位大虾,有多少人没听说SQL3(SQL99)的?统计下。不知道的要老实交待,知道的要说两句,别整天口口声声jdbc2,却对数据库发展所知甚少。:)
      

  6.   

    Oracle 在搞 SQLJ,Sybase 和 IBM 都跟的很紧。SQLJ0(Oracle), SQLJ1(Sybase)在 JDBC3.0 前推出。SQLJ2 中将有把 UDF 直接映射到 Java 方法的规范。
    Sun 的希望是将 JDBC 和 CCF 齐头并进。JDBC3.0 中将有 JDBC 关于 CCF 中 SPI 的定义。
    jBoss 的 Rickard Oberg 24 小时内完成了一个对纯文本文件的 JDBC driver。
    JNDI 中存放信息则是分布式编程环境下的一个趋势,你不用关心它的物理位置了。
    对一个厂家而言,无需开发源码让最终用户作复杂的配置了。
    东大 Alpine 好象有个数据库,不知有人用过没有。如果它愿意走开发源码的路线,大家可以帮它写个 driver。
      

  7.   

    Tommy兄:
        那里可以找到SQL99的资料?