tomcat 配置mysql 数据库连接池
tomcat 安装目录下的conf目录中的context.xml与web.xml文件分别修改如下:
context.xml 新加如下内容:
<Resource name="jdbc/mysql"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://数据库地址:3306/数据库名称?autoReconnect=true"
username="数据库用户名"
password="数据库密码"
maxActive="30"
maxIdle="30"
maxWait="10000"
removeAbandoned="true"
removeAbandonedTimeout="300"
logAbandoned="true"/>
web.xml 新增如下内容
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
相关文档:
作者:Dirk (dirk.ye AT gmail.com)
Url:http://dirk.pdx.cn
日期:2004/12/08
首先,目前在产品环境可用的MySQL版本(指4.0.x和4.1.x)中,只有InnoDB引擎才允许使用外键,所以,我们的数据表必须使用
InnoDB引擎。
下面,我们先创建以下测试用数据库
表:
CREATE TABLE `roottb` (
`id` INT(11) UNSIGNED AU ......
<!--
/* Font Definitions */
@font-face
{font-family:Courier;
panose-1:2 7 4 9 2 2 5 2 4 4;
mso-font-alt:"Courier New";
mso-font-charset:0;
mso-generic-font-family:modern;
mso-font-format:other;
mso-font-pitch:fixed;
mso-font-signature:3 0 0 0 1 0;}
@font-face
{f ......
1、打开MyEclipse6.6
2、选择菜单:Window/Open Perspective/MyEclipse Database Explorer,点击OK,在左边打开DB Brower窗口。
3、在DB Brower窗口内任意空白处击右键,选择New命令,弹出Database Driver窗口
4、本窗口各项说明:
Driver template: MySQL Connector/J 选择驱动模板
& ......
问题是这样的:
一张test的表,字符集采用的latin1。
select to_id from test where to_id='cn象_王';
+---------------+
| to_id |
+---------------+
| cn陶_陶 |
| cn象_王 |
+---------------+
2 rows in set (0.00 sec)
取cn象_王的数据,居然把cn陶_陶的数据也取回来了。
这显然是不允许的。
......
根据Chaos Wang的PPT整理而成, 在此再次感谢Chaos Wang的此次TechTalk
基本概念
• 字符(Character)是指人类语言中最小的表义符号。例如'A'、'B'等;
• 给定一系列字符,对每个字符赋予一个数值,用数值来代表对应的字符,这一数值就是字符的编码(Encoding)。例如,我们给字符'A'赋予数值0,给字符'B'赋予数值 ......