JSPÊý¾Ý¿âÁ¬½ÓÒÉÎÊ£¨Mysql£©
package com.wxpn.tutorial.db;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.Date;
/**
* ÃèÊö: Êý¾Ý¿âÁ¬½Ó³ØÀà
*
*
* @version 1.0
*/
public class ConnectionPool implements Runnable {
private boolean _debug = false;
private Thread runner;
private Connection[] connPool;
private int[] connStatus; // (0) available; (1) locked by the client; (2)
// locked by the housekeeping thread
private long[] connLockTime;
private long[] connCreateTime;
private String[] connID;
private String dbdriver, dbserver, dbuser, dbpassword;
private int currConnections, connLast, minconns, maxconns, maxconnMSec;
// available: set to false on destroy, checked by getConnection()
private boolean available = true;
private SQLWarning currSQLWarning;
/**
* Creates a new Connection Broker<br>
*
* @param dbdriver
* JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'<br>
* @param dbserver
* JDBC connect string. e.g.
* 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'<br>
* @param dbuser
* Database login name. e.g. 'Scott'<br>
* @param dbpassword
* Database password. e.g. 'Tiger'<br>
* @param minconns
* Minimum number of connections to start with.<br>
* @param maxconns
* &
Ïà¹ØÎĵµ£º
ÔÚZend FrameWorkÖе÷ÓÃmysqlµÄ´æ´¢¹ý³Ì·½·¨ÈçÏ£º
$db = Zend_Db::factory($sql_DbType,$sql_Config);
$connection=$db->getConnection();
Zend_Registry::set("db",$db);
Zend_Registry::set("connect",$connection);
µ÷Óô洢¹ý³ÌÈçÏ´úÂëËùʾ£º
$this->_db = Zend_Registry::get('db');
$connection=Zend_ ......
ת×Ôhttp://www.linuxbyte.org/yi-ge-mysql-server-shang-de-xiao-ji-qiao.html
ÔÚmy.cnf µÄ mysql ¶Ë Ìí¼ÓÈçÏÂÉèÖÃ
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
prompt="(\u:mysql1@linuxbyte.org \R:\m)[\d]: "
»á²úÉúÈçÏÂЧ¹û:
root@ubuntu:/home/hew# mysql -u hew -p
Enter pass ......
ÔÚÑ¡Ôñ´æ´¢ÒýÇæʱ£¬Ó¦¸ù¾ÝÓ¦ÓÃÌصãÑ¡ÔñºÏÊʵĴ洢ÒýÇ棬¶ÔÓÚ¸´ÔÓµÄÓ¦ÓÃϵͳ¿ÉÒÔ¸ù¾Ýʵ¼ÊÇé¿öÑ¡Ôñ¶àÖÖ´æ´¢ÒýÇæ½øÐÐ×éºÏ¡£
ÏÂÃæÊdz£Óô洢ÒýÇæµÄÊÊÓû·¾³¡£
¡ñMyISAM:ĬÈϵÄMysql²å¼þʽ´æ´¢ÒýÇæ¡£Èç¹ûÓ¦ÓÃÊÇÒÔ¶ÁдºÍ²åÈë²Ù×÷ΪÖ÷£¬Ö»ÓкÜÉÙ¸üкÍɾ³ý²Ù×÷£¬²¢ÇÒ¶ÔÊÂÎñÍêÕûÐÔ£¬²¢·¢ÐÔÒªÇó²»ÊǺܸߣ¬ÄÇÃ´Ñ ......
php½Ì³Ì mysql½Ì³Ì_connect Óëmysql_pconnectº¯ÊýÓëʵÀý½Ì³Ì
mysql_connect
mysql_connect($this->root,$this->user,$this->pass)
/*
mysql_connect ,µ¥¸ö·´ÎÊÓû§²»»áƵ·±µÄµ÷ÓÃÊý¾Ý¿â½Ì³Ì£¬Ã»±ØÒª±£³ÖÁ¬½Ó£¬¶øÇÒmysqlµÄÁ¬½ÓÊýÒ²ÊÇÓÐÏÞÖƵģ¬ ʹÓà ¼°Ê±·ÃÎʱȽÏƵ·±£¬Ò²×îºÃʹÓÃmysql_connect£¬ÕâÑùÊ¹Ó ......