<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    夢幻之旅

    DEBUG - 天道酬勤

       :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      671 隨筆 :: 6 文章 :: 256 評論 :: 0 Trackbacks

     

    <?xml version="1.0" encoding="UTF-8" ?>
    <beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi
    ="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation
    ="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
    >
     
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
            
    <property name="driverClass" value="com.mysql.jdbc.Driver" />
            
    <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/hwpok" />
            
    <property name="user" value="mydata" />
            
    <property name="password" value="123456" />
            
    <property name="autoCommitOnClose" value="true"/>
            
    <property name="checkoutTimeout" value="5000"/>
            
    <property name="initialPoolSize" value="2"/>
            
    <property name="minPoolSize" value="2"/>
            
    <property name="maxPoolSize" value="4"/>
            
    <property name="maxIdleTime" value="25200"/>
            
    <property name="acquireIncrement" value="1800"/>
            
    <property name="maxIdleTimeExcessConnections" value="5"/>
        
    </bean>
        
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
         
    <property name="dataSource" ref="dataSource" />
        
    </bean>
    </beans>

    測試:
    package hvp.spring.jdbc.jdbctemp;

    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    import org.springframework.jdbc.core.JdbcTemplate;
    import org.springframework.jdbc.datasource.DriverManagerDataSource;

    public class CreateTable
    {
        JdbcTemplate jt;
        
        
    public CreateTable()
        
    {
            
    this.jt = this.getJdbcTemplate2();
        }

        
        
    public JdbcTemplate getJdbcTemplate()
        
    {
            DriverManagerDataSource dmds 
    = new DriverManagerDataSource();
            dmds.setDriverClassName(
    "com.mysql.jdbc.Driver");
            dmds.setUrl(
    "jdbc:mysql://localhost:3306/hwpok");
            dmds.setUsername(
    "hwpok");
            dmds.setPassword(
    "123456");
            
            JdbcTemplate jdbcTemplate 
    = new JdbcTemplate();
            jdbcTemplate.setDataSource(dmds);
            
    return jdbcTemplate;
        }

        
        
    public JdbcTemplate getJdbcTemplate2()
        
    {
            String configPath 
    = "hvp/spring/jdbc/jdbctemp/beans.xml";
            ApplicationContext ctx 
    = new ClassPathXmlApplicationContext(configPath);
            
    return (JdbcTemplate) ctx.getBean("jdbcTemplate");
        }

        
        
    public void createTable()
        
    {
            StringBuffer sql 
    = new StringBuffer();
            sql.append(
    "CREATE TABLE t_user(");
            sql.append(
    "user_id int primary key,");
            sql.append(
    "user_name varchar(32)");
            sql.append(
    ")");
            jt.execute(sql.toString());
        }

        
        
    public static void main(String[] args)
        
    {
            CreateTable ct 
    = new CreateTable();
            ct.createTable();
        }

    }

    posted on 2008-08-10 12:36 HUIKK 閱讀(591) 評論(0)  編輯  收藏 所屬分類: Spring
    主站蜘蛛池模板: 又粗又黄又猛又爽大片免费| 亚洲精品色在线网站| 免费人成视网站在线观看不卡| 99视频在线免费| 巨胸狂喷奶水视频www网站免费| 最新亚洲春色Av无码专区| 久久久久久亚洲Av无码精品专口| 亚洲午夜福利精品无码| 国产精品成人免费综合| 好男人www免费高清视频在线| 十八禁无码免费网站| 中国一级特黄高清免费的大片中国一级黄色片 | 成人免费无遮挡无码黄漫视频| 一级特黄aa毛片免费观看| 97在线免费视频| 国产日韩在线视频免费播放| 黄人成a动漫片免费网站| 亚洲av成人中文无码专区| 亚洲精品亚洲人成在线播放| 99久久精品国产亚洲| 午夜亚洲国产理论秋霞| 久久国产亚洲精品麻豆| 成人午夜亚洲精品无码网站| 四虎永久成人免费| 国产免费小视频在线观看| 日本v片免费一区二区三区| 午夜a级成人免费毛片| 性色av免费观看| 四虎影视www四虎免费| 免费看片A级毛片免费看| 日韩在线天堂免费观看| 午夜毛片不卡高清免费| 永久免费无码网站在线观看| 成人毛片18女人毛片免费| 成人免费在线观看网站| 日韩成人免费aa在线看| 免费在线观看理论片| 亚洲乱码中文字幕综合234| 亚洲日韩中文无码久久| 亚洲AV永久无码精品| 亚洲色欲www综合网|