Java????????Proxool
?????Sharpest ???????[ 2016/7/14 10:19:38 ] ??????????????????? Java
????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 }
??????
![](/images/ad-banner/ad-banner.png)
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11