易截截图软件、单文件、免安装、纯绿色、仅160KB

tomcat 6.0 + mysql + jndi 数据库连接池配置

1、新建动态web项目。
2、添加jar包
    将mysql jdbc驱动添加到tomcat安装目录下的lib目录。
3、在META-INF下添加content.xml文件。内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true" crossContext="true">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>

<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/spring"
username="root" password="123456" maxActive="20" maxIdle="10"
maxWait="10000" />
</Context>
WatchedResource - The auto deployer will monitor the specified static resource of the web application for updates, and will reload the web application if is is updated. The content of this element must be a string.
4、连接jdbc的Java代码:
package cn.guopeng.dbcp.dbconn;
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
public class MySqlDbconn {
public static Connection getConnection(){
Connection conn = null;
try {
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/mydb");
conn = ds.getConnection();
} catch (NamingException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
}


相关文档:

MySQL集群

1,将6.0版本的mysql集群软件上传到Linux或是Solaris上,解压
 
 1>,为了方便调用将其改名为mysql,并且放于/usr/local/下
 2>,创建连接文件,进入/usr/local/下
  
  ln -s ..../mysql mysql
2,创建组,添加用户
 
 groupadd mysql
 useradd -g mysq ......

Mysql 常用函数


 
Mysql 常用函数
ASCII(str) 
 返回字符串str的第一个字符的ASCII值(str是空串时返回0) 
mysql> select ASCII('2'); 
  -> 50 
mysql> select ASCII(2); 
  -> 50 
mysql> select ASCII('dete'); 
  - ......

python链接mysql常见问题

Python与Mysql
一、安装MySQLdb模块
使用python连接Mysql的前提,就是需要一个让python连接到Mysql的接口,这就是MySQLdb模块。
验证是否已经安装了MySQLdb:
==========================================================
d:\usr\local\Python25>python
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v ......

mysql备份

对于中等级别业务量的系统来说,备份策略可以这么定:第一次全量备份,每天一次增量备份,每周再做一次全量备份,如此一直重复。而对于重要的且繁忙的系统 来说,则可能需要每天一次全量备份,每小时一次增量备份,甚至更频繁。为了不影响线上业务,实现在线备份,并且能增量备份,最好的办法就是采用主从复制机 制(replica ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号