您的位置:首页 >> 编程开发 >> Java >> 数据库 >> 正文
数据库 RSS
 

JDBC是如何连接数据库的?

http://www.rdxx.com 01年11月16日 11:06 互联网 我要投稿

关键词: 连接数据库 , JDBC , 数据 , 连接 , JDB

   }
 
  static
    {
        if(JdbcOdbcObject.isTracing())
            JdbcOdbcObject.trace("JdbcOdbcDriver class loaded");
        JdbcOdbcDriver jdbcodbcdriver = new JdbcOdbcDriver();
        try
        {
            DriverManager.registerDriver(jdbcodbcdriver);
        }
        catch(SQLException sqlexception)
        {
            if(JdbcOdbcObject.isTracing())
                JdbcOdbcObject.trace("Unable to register driver");
        }
    }
}

public interface JdbcOdbcDriverInterface
    extends Driver
{
  ...
}

3 连接过程
jdbc.sql.Connection con =
            DriverManager.getConnection("jdbc:odbc:pubs","sa","");

public class DriverManager {
public static synchronized Connection getConnection(String url,
              String user, String password) throws SQLException {
        java.util.Properties info = new java.util.Properties();

        // Gets the classloader of the code that called this method, may
 // be null.
 ClassLoader callerCL = DriverManager.getCallerClassLoader();

 if (user != null) {
     info.put("user", user);
 }
 if (password != null) {
     info.put("password", password);
 }

        return (getConnection(url, info, callerCL));
}
private static synchronized Connection getConnection(
        String url,
        java.util.Properties info,
        ClassLoader callerCL) throws SQLException
{
...
Connection result = di.driver.connect(url, info);
...
}             
}
4  结构图:
请点击查看 结构图   http://jdeveloper.myrice.com/doc/jdbc/images/howjdbc.jpg

请到 http://jdeveloper.myrice.com/ 看更多的Java文章

9 7 3 1 2 4 8 :


 
 
标签: 连接数据库 , JDBC , 数据 , 连接 , JDB 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站