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

JDBC+MySQL连接池

1.创建一个java project项目pooling
2.为项目添加MySQL连接驱动
3.为项目添加一个配置文件dbpool.proprerties
Code
driverClassName=com.mysql.jdbc.Driver
username=root
password=
url=jdbc:mysql://localhost:3306/work
poolSize=10
 
4.分别创建一个连接类ConnectionPool.java和一个测试类ConnectionPoolTest.java(代码)
 
Code
package webbook.util;
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
import java.util.Vector;
public class ConnectionPool {
    private Vector<Connection> pool;
    private String url;
    private String username;
    private String password;
    private String driverClassName;
    /**
     * 连接池的大小,也就是连接池中有多少个数据库连接。
     */
    private int poolSize = 1;
    private static ConnectionPool instance = null;
    /**
     * 私有的构造方法,禁止外部创建本类的对象,要想获得本类的对象,通过<code>getIstance</code>方法。
     * 使用了设计模式中的单子模式。
     */
    private ConnectionPool() {
        init();
    }
    /**
     * 连接池初始化方法,读取属性文件的内容 建立连接池中的初始连接
     */
    private void init() {
        pool = new Vector<Connection>(poolSize);
    &nb


相关文档:

mysql alter 语句用法,添加、修改、删除字段等


//主键
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
//增加一个新列
alter table t2 add d timestamp;
alter table infos add ex tinyint not null default '0';
//删除列
alter table t2 drop column c;
//重命名列
......

Mysql limit用法

1.SELECT
 
*
 
from
 
table
 LIMIT
1
,
20
;  
//
 检索记录行
2-21
   第一个参数:查询起始行(从0开始)
   第二个参数:查询几条记录
2.
SELECT
 
*
 
from
 
table
 LIMIT
5
,
-
1

//
&nbs ......

MySQL的datetime设置当前时间为默认值


MySQL的datetime设置当前时间为默认值 
由于MySQL目前字段的默认值不支持函数,所以用
create_time datetime default now()
的形式设置默认值是不可能的。
代替的方案是使用TIMESTAMP类型代替DATETIME类型。
CURRENT_TIMESTAMP :当我更新这条记录的时候,这条记录的这个字段不会改变

CURRENT_TIMESTAMP O ......

C#连接MySQL进行操作的方法

由于需要实现以下功能:
网关通过串口发送数据给PC机,PC机收集数据并解析保存到MySQL中,然后JSP页面读取MySQL中的数据并显示。
所以利用C#连接MySQL数据成为了必须要经过的过程,在此给予详细的说明。
1、下载需要的文件MySQLDriverCS,下载地址为:http://sourceforge.net/projects/mysqldrivercs
2、安装文件:MySQ ......

多服务器共享session(mysql)

<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
//===========================================
// 程序: mysql-Based Session Class
// 功能: 基于mysql存储的 Session 功能类
// 作者: yejr
// 网站: http://imysql.cn
// 时间: 2007- ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号