????1.
1 package com.asm;
2
3 import java.io.File;
4 import java.io.InputStream;
5 import java.sql.Connection;
6 import java.sql.DriverManager;
7 import java.sql.ResultSet;
8 import java.sql.Statement;
9
10 import org.junit.Test;
11 import org.logicalcobwebs.proxool.configuration.JAXPConfigurator;
12 import org.springframework.test.context.TestExecutionListeners;
13
14 public class TestProxool {
15     public static String dburl = "jdbc:mysql://localhost:3306/test";
16     public static String user = "root";
17     public static String password = "123456";
18
19     /**
20      * ????/** ????* JDBC??????? ????* ????* @throws Exception
21      */
22     @Test
23     public void test() throws Exception {
24         String testsql = "select * from village t where lastid = 1";
25         // 1???????????
26         Class.forName("com.mysql.jdbc.Driver");
27         // 2???????????????
28         Connection conn = DriverManager.getConnection(dburl?? user?? password);
29         // 3?????????SQL?????
30         Statement stmt = conn.createStatement();
31         // 4?????SQL?????????????
32         ResultSet rs = stmt.executeQuery(testsql);
33         // 5?????????????????????????
34         while (rs.next()) {
35             System.out.print(rs.getLong("lastid") + " ");
36             System.out.print(rs.getString("lastname") + " ");
37             System.out.println();
38         }
39         // 6??????????????
40         conn.close();
41     }
42
43     /**
44      * ????* proxool??????? ????* ????* @throws Exception
45      */
46     @Test
47     public  void test2() throws Exception {
48         //Java????????????????????????????????????????
49         JAXPConfigurator.configure("F:\hysworkspace1\ProxoolTest\src\proxool.xml"?? false);
50         String testsql = "select * from village t where lastid = 1";
51         //1????????????????????????????Oracle???????????Proxool????????
52         Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
53         //2?????????????????????????????????????????????????????????????????timalias????????????proxool.??????????
54         Connection conn = DriverManager.getConnection("proxool.timalias");
55         //3?????????SQL?????
56         Statement stmt = conn.createStatement();
57         //4?????SQL?????????????
58         ResultSet rs = stmt.executeQuery(testsql);
59         //5?????????????????????????
60         while (rs.next()) {
61             System.out.print(rs.getLong("lastid") + " ");
62             System.out.print(rs.getString("lastname") + " ");
63         System.out.println();
64         }
65         //6??????????????
66         conn.close();
67     }
68 }