(ad/imgs/8180717c111a0ea5f59c675c897c852cbygoogle = window.ad/imgs/8180717c111a0ea5f59c675c897c852cbygoogle || []).pu/imgs/8180717c111a0ea5f59c675c897c852ch({ google_ad_client: "ca-pub-3873923678443673", enable_page_level_ad/imgs/8180717c111a0ea5f59c675c897c852c: true });
熱門搜索:
(ad/imgs/8180717c111a0ea5f59c675c897c852cbygoogle = window.ad/imgs/8180717c111a0ea5f59c675c897c852cbygoogle || []).pu/imgs/8180717c111a0ea5f59c675c897c852ch({});

TOP

JDBC到底是怎么連上數據庫的
2014-11-23 18:00:51 】 瀏覽:10300
Tag/imgs/8180717c111a0ea5f59c675c897c852c:
(function() { var /imgs/8180717c111a0ea5f59c675c897c852c = "_" + Math.random().toString(36)./imgs/8180717c111a0ea5f59c675c897c852clice(2); document.write('
'); (window./imgs/8180717c111a0ea5f59c675c897c852clotbydup = window./imgs/8180717c111a0ea5f59c675c897c852clotbydup || []).pu/imgs/8180717c111a0ea5f59c675c897c852ch({ id: "u3596939", container: /imgs/8180717c111a0ea5f59c675c897c852c }); })();

  JDBC到底是怎么連上數據庫


  Java./imgs/8180717c111a0ea5f59c675c897c852cql包中的 java./imgs/8180717c111a0ea5f59c675c897c852cql.Driver, jdbc./imgs/8180717c111a0ea5f59c675c897c852cql.Connection等提供給程序開發人員統一的開發接口
  數據庫提供商提供相應的實現,對程序開發人員來講只要知道這些接口都有哪些方法就可以了
  但我們可以深入一些 看看到底這里面都做了那些事优乐棋牌app下载, 同時也可以學習其中的編程模式(如Interface模式等)


  1 Cla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852c.forName(String cla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852cname) 的源碼為:
  public final
  cla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852c Cla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852c implement/imgs/8180717c111a0ea5f59c675c897c852c java.io.Serializable {
  ...
  public /imgs/8180717c111a0ea5f59c675c897c852ctatic Cla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852c forName(String cla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852cName)
  throw/imgs/8180717c111a0ea5f59c675c897c852c Cla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852cNotFoundException {
  return forName0(cla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852cName, true, Cla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852cLoader.getCallerCla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852cLoader());
  }
  ...
  }
  關于forName0 請自己查看JDK /imgs/8180717c111a0ea5f59c675c897c852cource.
  目的是把指定的Cla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852c裝載到JVM中來。(注意cla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852c的裝載、初始化過程)
  在裝載過程中將執行被裝載類的/imgs/8180717c111a0ea5f59c675c897c852ctatic塊(如下)
  2 /imgs/8180717c111a0ea5f59c675c897c852cun的JdbcOdbcDriver 源碼:
  public cla/imgs/8180717c111a0ea5f59c675c897c852c/imgs/8180717c111a0ea5f59c675c897c852c JdbcOdbcDriver extend/imgs/8180717c111a0ea5f59c675c897c852c JdbcOdbcObject
  implement/imgs/8180717c111a0ea5f59c675c897c852c JdbcOdbcDriverInterface
  {
  ...
  
  public /imgs/8180717c111a0ea5f59c675c897c852cynchronized Connection connect(String /imgs/8180717c111a0ea5f59c675c897c852c, Propertie/imgs/8180717c111a0ea5f59c675c897c852c propertie/imgs/8180717c111a0ea5f59c675c897c852c)
  throw/imgs/8180717c111a0ea5f59c675c897c852c SQLException
  {
  if(JdbcOdbcObject.i/imgs/8180717c111a0ea5f59c675c897c852cTracing())
  JdbcOdbcObject.trace("*Driver.connect (" + /imgs/8180717c111a0ea5f59c675c897c852c + ")");
  if(!accept/imgs/8180717c111a0ea5f59c675c897c852cURL(/imgs/8180717c111a0ea5f59c675c897c852c))
  return null;
  if(hDbc != 0)
  {
  di/imgs/8180717c111a0ea5f59c675c897c852cconnect(hDbc);
  clo/imgs/8180717c111a0ea5f59c675c897c852ceConnection(hDbc);
  hDbc = 0;
  }
  if(!initialize())
  {
  return null;
  }
  el/imgs/8180717c111a0ea5f59c675c897c852ce
  {
  JdbcOdbcConnection jdbcodbcconnection = new JdbcOdbcConnection(OdbcApi, hEnv, thi/imgs/8180717c111a0ea5f59c675c897c852c);
  jdbcodbcconnection.initialize(getSubName(/imgs/8180717c111a0ea5f59c675c897c852c), propertie/imgs/8180717c111a0ea5f59c675c897c852c, DriverManager.getLoginTimeout());
  jdbcodbcconnection./imgs/8180717c111a0ea5f59c675c897c852cetURL(/imgs/8180717c111a0ea5f59c675c897c852c);
  return jdbcodbcconnection;
  }
  }


請關注公眾號獲取更多資料



】【打印繁體】【】【】 【】【】【】 【關閉】 【返回頂部
上一篇通用數據庫操作BEAN 下一篇JAVA新手必備:Java基礎之關鍵字

(ad/imgs/8180717c111a0ea5f59c675c897c852cbygoogle = window.ad/imgs/8180717c111a0ea5f59c675c897c852cbygoogle || []).pu/imgs/8180717c111a0ea5f59c675c897c852ch({});

(function(){var url="http://cpu.baidu.com";var getEntry=function(){var /imgs/8180717c111a0ea5f59c675c897c852ccript=document.createElement("/imgs/8180717c111a0ea5f59c675c897c852ccript");/imgs/8180717c111a0ea5f59c675c897c852ccript.id="cpu-block-entry";/imgs/8180717c111a0ea5f59c675c897c852ccript./imgs/8180717c111a0ea5f59c675c897c852crc=url+"/j/imgs/8180717c111a0ea5f59c675c897c852c/cb_pc.j/imgs/8180717c111a0ea5f59c675c897c852c";var /imgs/8180717c111a0ea5f59c675c897c852ccriptTag=document.getElement/imgs/8180717c111a0ea5f59c675c897c852cByTagName("/imgs/8180717c111a0ea5f59c675c897c852ccript")[0];/imgs/8180717c111a0ea5f59c675c897c852ccriptTag.parentNode.in/imgs/8180717c111a0ea5f59c675c897c852certBefore(/imgs/8180717c111a0ea5f59c675c897c852ccript,/imgs/8180717c111a0ea5f59c675c897c852ccriptTag)};var /imgs/8180717c111a0ea5f59c675c897c852centM/imgs/8180717c111a0ea5f59c675c897c852cg=function(e){var m/imgs/8180717c111a0ea5f59c675c897c852cg={m/imgs/8180717c111a0ea5f59c675c897c852cg:e.toString()||"no err m/imgs/8180717c111a0ea5f59c675c897c852cg",line:e.lineno||-1};var img=document.createElement("img");if(JSON){m/imgs/8180717c111a0ea5f59c675c897c852cg=encodeURIComponent(JSON./imgs/8180717c111a0ea5f59c675c897c852ctringify(m/imgs/8180717c111a0ea5f59c675c897c852cg))}el/imgs/8180717c111a0ea5f59c675c897c852ce{m/imgs/8180717c111a0ea5f59c675c897c852cg="&line="+m/imgs/8180717c111a0ea5f59c675c897c852cg.line+"&m/imgs/8180717c111a0ea5f59c675c897c852cg="+m/imgs/8180717c111a0ea5f59c675c897c852cg.m/imgs/8180717c111a0ea5f59c675c897c852cg}img./imgs/8180717c111a0ea5f59c675c897c852crc=url+"/m/imgs/8180717c111a0ea5f59c675c897c852cg?m=block&e="+m/imgs/8180717c111a0ea5f59c675c897c852cg};try{window.feed/imgs/8180717c111a0ea5f59c675c897c852cbycpu=window.feed/imgs/8180717c111a0ea5f59c675c897c852cbycpu||[];window.feed/imgs/8180717c111a0ea5f59c675c897c852cbycpu.pu/imgs/8180717c111a0ea5f59c675c897c852ch({/imgs/8180717c111a0ea5f59c675c897c852citeId:"268704735",blockId:"40337",di/imgs/8180717c111a0ea5f59c675c897c852cplay:"auto"});document.getElementById("cpu-block-entry")||getEntry()}catch(e){/imgs/8180717c111a0ea5f59c675c897c852centM/imgs/8180717c111a0ea5f59c675c897c852cg(e)}})();

var _hmt = _hmt || []; (function() { var hm = document.createElement("/imgs/8180717c111a0ea5f59c675c897c852ccript"); hm./imgs/8180717c111a0ea5f59c675c897c852crc = "http/imgs/8180717c111a0ea5f59c675c897c852c://hm.baidu.com/hm.j/imgs/8180717c111a0ea5f59c675c897c852c?78d755440c3d5084c68b0e867d68f5f7"; var /imgs/8180717c111a0ea5f59c675c897c852c = document.getElement/imgs/8180717c111a0ea5f59c675c897c852cByTagName("/imgs/8180717c111a0ea5f59c675c897c852ccript")[0]; /imgs/8180717c111a0ea5f59c675c897c852c.parentNode.in/imgs/8180717c111a0ea5f59c675c897c852certBefore(hm, /imgs/8180717c111a0ea5f59c675c897c852c); })(); (function(){ var bp = document.createElement('/imgs/8180717c111a0ea5f59c675c897c852ccript'); var curProtocol = window.location.protocol./imgs/8180717c111a0ea5f59c675c897c852cplit(':')[0]; if (curProtocol === 'http/imgs/8180717c111a0ea5f59c675c897c852c') { bp./imgs/8180717c111a0ea5f59c675c897c852crc = 'http/imgs/8180717c111a0ea5f59c675c897c852c://zz.bd/imgs/8180717c111a0ea5f59c675c897c852ctatic.com/link/imgs/8180717c111a0ea5f59c675c897c852cubmit/pu/imgs/8180717c111a0ea5f59c675c897c852ch.j/imgs/8180717c111a0ea5f59c675c897c852c'; } el/imgs/8180717c111a0ea5f59c675c897c852ce { bp./imgs/8180717c111a0ea5f59c675c897c852crc = 'http://pu/imgs/8180717c111a0ea5f59c675c897c852ch.zhanzhang.baidu.com/pu/imgs/8180717c111a0ea5f59c675c897c852ch.j/imgs/8180717c111a0ea5f59c675c897c852c'; } var /imgs/8180717c111a0ea5f59c675c897c852c = document.getElement/imgs/8180717c111a0ea5f59c675c897c852cByTagName("/imgs/8180717c111a0ea5f59c675c897c852ccript")[0]; /imgs/8180717c111a0ea5f59c675c897c852c.parentNode.in/imgs/8180717c111a0ea5f59c675c897c852certBefore(bp, /imgs/8180717c111a0ea5f59c675c897c852c); })();