首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

[]应用JDBC时Class.forName()的作用

2012-10-06 
[]使用JDBC时Class.forName()的作用使用jdbc时,我们都会很自然得使用下列语句: package com.mysql.jdbcpub

[]使用JDBC时Class.forName()的作用
    使用jdbc时,我们都会很自然得使用下列语句:

package com.mysql.jdbc       public class driver extends nonregisteringdriver implements java.sql.driver {     // ~ static fields/initializers     // --------------------------------------------- //     // register ourselves with the drivermanager     //     static {        t ry {                  java.sql.drivermanager.registerdriver(new driver());              } catch (sqlexception e) {                  throw new runtimeexception("can't register driver!");              }      }    // ~ constructors     // -----------------------    /**     * construct a new driver and register it with drivermanager     *      * @throws sqlexception     *             if a database error occurs.     */    public driver() throws sqlexception {         // required for class.forname().newinstance()     }    }   
 

热点排行