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

Proxool来连接mysql介绍

本文主要介绍了采用Proxool来连接mysql的方法,通过java  application方式可以验证数据库的连接及获取表中的数据。为了能够与传统的JDBC方式的连接进行比较,本文采取了两种方式进行数据库的连接,代码如下。
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.logicalcobwebs.proxool.configuration.JAXPConfigurator;
public class TestProxool {
public static String dburl = "jdbc:mysql://localhost:3306/dma";
public static String user = "root";
public static String password = "888888";

public static void test1() throws Exception {
String testsql = "select * from user where userID = 13";
//1:注册驱动类
Class.forName("com.mysql.jdbc.Driver");
//2:创建数据库连接
Connection conn = DriverManager.getConnection(dburl, user, password);
//3:创建执行SQL的对象
Statement stmt = conn.createStatement();
//4:执行SQL,并获取返回结果
ResultSet rs = stmt.executeQuery(testsql);
//5:处理返回结果,此处打印查询结果
while (rs.next()) {
System.out.print(rs.getInt("userID") + "\t");
System.out.print(rs.getString("sourceIP") + "\t");
System.out.println();
}
//6:关闭数据库连接
conn.close();
}

/**
* proxool方式测试
*
* @throws Exception
*/
public static void test2() throws Exception {
//加载配置文件,配置文件可以是相对路径,也可以是绝对路径
JAXPConfigurator.configure("proxool.xml", false);
// System.out.println("You have already load the xml file");
String testsql = "select * from user where userID = 13";
//1:注册驱动类,是Proxool专用的驱动
Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
//2:创建数据库连接,这个参数是一个字符串,是数据源的别名,在配置文件中配置的dma,参数格式为:proxool.数据源的别名
Connection conn = DriverManage


相关文档:

MySQL 随笔

1, MySQL profiling
 mysql> set profiling = 1;
 mysql> select count(*) from test;
 mysql> show profiles;
 mysql> show profile for query 1;
2,mysql 监控
http://bbs.linuxtone.org/thread-1854-1-1.html
http://code.google.com/p/mysql-cacti-templates/   -> Hig ......

Mysql Explain 详解[强烈推荐]

Mysql Explain 详解
一.语法
explain < table_name >
例如: explain select * from t3 where id=3952602;
二.explain输出解释
+----+-------------+-------+-------+-------------------+---------+---------+-------+------+-------+
| id | select_type | table | type  | possible_keys  &nb ......

mysql启动和关闭约束的方法(FOREIGN_KEY_CHECKS)


mysql启动和关闭约束的方法(FOREIGN_KEY_CHECKS)
2009-07-06 16:43
MySQL还原数据库,禁用和启用外键约束的方法(FOREIGN_KEY_CHECKS)
有时还原数据库时,因为表有约束导致40014错误,可以通过关闭外键约束,还原成功时再启用
禁用
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0
启用
S ......

MYSQL常用命令列表


MYSQL常用命令列表
1、系统管理
mysql -h主机地址 -u用户名 -p 
连接MYSQL(在mysql/bin)
exit 
退出MYSQL命令
mysqladmin -u用户名 -p旧密码 password新密码 
修改密码(在mysql/bin)
grantselect[insert][,update][,delete]on数据库.*to用户名@localhost("%", 表示任何主机)identifiedby " ......

mysql ibdata1文件的缩小

mysql ibdata1文件的缩小(2009-12-22 15:29:46)
标签:it 
 
mysql ibdata1存放数据,索引等,是MYSQL的最主要的数据。
如果不把数据分开存放的话,这个文件的大小很容易就上了G,甚至10+G。对于某些应用来说,并不是太合适。因此要把此文件缩小。
方法:数据文件单独存放。
步骤:
1,备份数据库
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号