常ç¨çæ°æ®åºè¿æ¥æ± æ以ä¸å ç§ï¼
1.åºäºJNDI ãC3P0 ãDBCPææ¯çæ°æ®è¿æ¥æ±
ï¼1ï¼JNDI(Java Naming and Directory Interface ):æ¯SUNå
¬å¸æä¾çä¸ç§æ åçJavaå½åç³»ç»æ¥å£ï¼æ¯ä¸ç»å¨Javaåºç¨ä¸è®¿é®å½ååç®å½æå¡çAPIãå½åæå¡æ¯å°å称å对象è系起æ¥ï¼ä½¿å¾æ们å¯ä»¥ç¨å称访é®å¯¹è±¡ãç®å½æå¡æ¯ä¸ç§å½åæå¡,å®æä¾äºåºç¨ç¼ç¨æ¥å£(application
programming interfaceï¼API)åæå¡æä¾è
æ¥å£(service provider interfaceï¼SPI)ãè¿ä¸ç¹ççæ£å«ä¹æ¯ï¼è¦è®©åºç¨ä¸å½åæå¡æç®å½æå¡äº¤äºï¼å¿
é¡»æè¿ä¸ªæå¡çJNDIæå¡æä¾è
ï¼è¿æ£æ¯JNDI
SPIåæ¥ä½ç¨çå°æ¹ãæå¡æä¾è
åºæ¬ä¸æ¯ä¸ç»ç±»ï¼è¿äºç±»ä¸ºåç§å
·ä½çå½ååç®å½æå¡å®ç°äºJNDIæ¥å£âå¾è±¡JDBC驱å¨ä¸ºåç§å
·ä½çæ°æ®åºç³»ç»å®ç°äºJDBCæ¥å£ä¸æ ·ãä½ä¸ºä¸ä¸ªåºç¨å¼åè
ï¼ä¸å¿
æå¿JNDI
SPIãåªéè¦ç¡®è®¤è¦ä½¿ç¨çæ¯ä¸ä¸ªå½åæç®å½æå¡é½ææå¡æä¾è
ã
ï¼2ï¼C3P0:è¿æ¥æ± ä½è
æ¯ãæç大æãè¿·ï¼C3P0å°±æ¯å
¶ä¸çä¸ä¸ªæºå¨äººï¼å¹¶ä¸è¿ä¸ªå称ä¸å
涵connection åpoolçåè¯åæ¯ãå æ¤å«è¿ä¸ªååã
ï¼3ï¼DBCP(DataBase connection pool)ï¼æ¯ apache ä¸çä¸ä¸ª java è¿æ¥æ± 项ç®ï¼ä¹æ¯ tomcat
使ç¨çè¿æ¥æ± ç»ä»¶ãåç¬ä½¿ç¨dbcpéè¦3个å
ï¼common-dbcp.jar,common-pool.jar ,common-collections.jar
(4)JDBC(Java DataBase
Connectivity)æ¯Javaä¸æ°æ®åºçæ¥å£è§èï¼JDBCå®ä¹äºä¸ä¸ªæ¯ææ åSQLåè½çéç¨ä½å±çåºç¨ç¨åºç¼ç¨æ¥å£(API)ï¼å®ç±Java
è¯è¨ç¼åçç±»åæ¥å£ç»æï¼æ¨å¨è®©åæ°æ®åºå¼åå为Javaç¨åºåæä¾æ åçæ°æ®åºAPIã JDBC
APIå®ä¹äºè¥å¹²Javaä¸çç±»ï¼è¡¨ç¤ºæ°æ®åºè¿æ¥ãSQLæ令ãç»æéãæ°æ®åºå
æ°æ®çãå®å
许Javaç¨åºååéSQLæ令并å¤çç»æãéè¿é©±å¨ç¨åºç®¡çå¨,JDBC
APIå¯å©ç¨ä¸åç驱å¨ç¨åºè¿æ¥ä¸åçæ°æ®åºç³»ç»ã
(5)ODBCï¼Open DataBase
Connectivityï¼æ¯å¾®è½¯å¡å¯¼çãå½å被ä¸ç广æ³æ¥åçãç¨äºæ°æ®åºè®¿é®çåºç¨ç¨åºç¼ç¨æ¥å£ï¼APIï¼ï¼å®ä»¥X/Openå
ISO/IECçè°ç¨çº§æ¥å£(CLI)è§è为åºç¡ï¼å¹¶ä½¿ç¨ç»æåæ¥è¯¢è¯è¨ï¼SQLï¼ä½ä¸ºå
¶æ°æ®åºè®¿é®è¯è¨ã ODBCæ»ä½ç»ææå个ç»ä»¶ï¼
åºå«åèç³»ï¼
JDBCä¸ODBCé½æ¯åºäºX/OpençSQLè°ç¨çº§æ¥å£ï¼
JDBCç设计å¨ææ³ä¸æ²¿è¢äºODBCï¼åæ¶å¨å
¶ä¸»è¦æ½è±¡åSQL
CLIå®ç°ä¸ä¹æ²¿è¢äºODBCï¼è¿ä½¿å¾JDBC容æ被æ¥åãJDBCçæ»ä½ç»æ类似äºODBCï¼ä¹æå个ç»ä»¶ï¼åºç¨ç¨åºã驱å¨ç¨åºç®¡çå¨ã驱å¨ç¨åºåæ°æ®æºã
JDBCä¿æäºODBCçåºæ¬ç¹æ§ï¼ä¹ç¬ç«äºç¹å®æ°æ®åºã
追ç亲ï¼æçåçä½ æ»¡æåï¼ç»ä¸ªå¥½è¯å§ï¼æè
ä½ å¯ä»¥ç»§ç»é®æå¦