首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

proxool配备

2012-07-29 
proxool配置项目结构所需jar包proxool.propertiesjdbc-0.proxool.aliasmysql_aliasjdbc-0.proxool.driver

proxool配置
项目结构



所需jar包



proxool.properties

jdbc-0.proxool.alias=mysql_aliasjdbc-0.proxool.driver-url=jdbc:mysql://127.0.0.1:3306/tianbao_zzjzjdbc-0.proxool.driver-class=com.mysql.jdbc.Driverjdbc-0.user=liuwentaojdbc-0.password=123456jdbc-0.proxool.maximum-connection-count=10jdbc-0.proxool.house-keeping-test-sql=select CURRENT_DATE

Test01
package demo.proxool;import org.logicalcobwebs.proxool.ProxoolException;import org.logicalcobwebs.proxool.configuration.PropertyConfigurator;import java.sql.*;/** * User: liuwentao * Time: 12-6-12 上午10:43 */public class Test01 {    /**     * 获得连接     * @return     */    public static Connection getConnection() {        Connection conn = null;        try {            PropertyConfigurator.configure("src/proxool.properties");            conn = DriverManager.getConnection("proxool.mysql_alias");        } catch (ProxoolException e) {            e.printStackTrace();        } catch (SQLException e) {            e.printStackTrace();        }        return conn;    }    public static void main(String[] args) {        Connection conn = Test01.getConnection();        Statement stmt = null;        try {            stmt = conn.createStatement();//            String sql_insert = "CREATE TABLE col_link (sitename varchar (20) NULL ,siteurl varchar (50) NULL) ";//            stmt.executeUpdate(sql_insert);//            stmt.executeUpdate("insert into col_link values('ASP中华网','http://www.aspcn.com')");//            stmt.executeUpdate("insert into col_link values('永远到底有多远','http://xuankong.com')");//            //执行一个insert into语句//            stmt.executeUpdate("update col_link set siteurl='http://www.aspcn.com/xuankong/xuankongt.jpg' where siteurl='http://xuankong.com'");            String sql_query = "select * from zzjz_owner order by id";            ResultSet rs = stmt.executeQuery(sql_query);            System.out.println("---------------" + " " + "----------------");            while (rs.next()) {                String title = rs.getString("title");                String domain = rs.getString("domain");                /**                 String title = rs.getString(1);                 String domain = rs.getString(2);                 **/                System.out.println(title + "," + domain);            }        } catch (SQLException e) {            e.printStackTrace();        } finally {            try {                stmt.close();                conn.close();            } catch (SQLException e) {                e.printStackTrace();            }        }    }}


结果:



热点排行