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
    
     
	
	
    
    
	相关文档:
        
    
    经常在一个表中有父子关系的两个字段,比如empno与manager,这种结构中需要用到树的遍历。在Oracle 中可以使用connect by简单解决问题,参见http://blog.csdn.net/ylqmf/archive/2010/01/11/5172866.aspx,但MySQL 5.1中还不支持(据说已纳入to do中),要自己写过程或函数来实现。
一、建立测试表和数据:
view plaincop ......
	
    
        
    
    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中用select实现TOP N功能
先说几个关键字:
distinct 返回不重复的多列
count() 计数
limit m,n 第m个起n个
 
那么,如果需要查找名为col的某一个列的Top N,并列出对应的值的select语句就如下:
select dinstinct(col),count(col) from tablename group by 1 order  ......
	
    
        
    
    mysql服务器安装配置:
1. sudp apt-get install mysql-server-5.0
2. 创建库second_proxy, 为secProxy添加用户:grant all privileges on second_proxy.* to secProxy@'%' identified by 'passwd';
3. 设置mysql.user表如下:
+-----------+------------------+-------------------------------------------+
| Host& ......
	
    
        
    
    mysql常用命令 
  
关闭数据库 
/data01/mysql/bin/mysqladmin -p shutdown 
导出数据库 
/usr/local/mysql/bin/mysqldump -opt -uroot -p -h10.15.0.45 bbsdb > 20070918.bbsdb.sql 
导入数据库 
/usr/local/mysql/bin/mysql target_db_name < backup-file.sql 
限制只有内部ip可以链接 
/u ......