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

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

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

    First they ignore you
    then they ridicule you
    then they fight you
    then you win
        -- Mahatma Gandhi
    Chinese => English     英文 => 中文             
    隨筆-221  評(píng)論-1047  文章-0  trackbacks-0
    ? 在特殊情況下,grails應(yīng)用需要調(diào)用數(shù)據(jù)庫(kù)的存儲(chǔ)過(guò)程,這在grails的官方文檔里邊好像沒(méi)有提到過(guò),在james的blog里介紹如何解決這個(gè)問(wèn)題。
    ??? 代碼轉(zhuǎn)貼如下
    java 代碼
    ?
    1. class?MainController?{??
    2. ??
    3. ??def?dataSource?//?using?the?datasource?we?define?in?the?spring's?resources.xml??
    4. ??
    5. ??def?index?=?{??
    6. ??????Sql?sql?=?new?Sql(dataSource)??
    7. ??????def?row?=?sql.execute("call?create_daily_hours(${new?Date()+1})")??
    8. ??}??
    9. }??
    ? 需要說(shuō)明的一些是:grails本身沒(méi)有提供訪問(wèn)存儲(chǔ)過(guò)程的便捷方法,而groovy的GSQL提供了,因此grails可以直接拿過(guò)來(lái)用了,當(dāng)然也可以用spring的JdbcTemplate。
    ? 希望對(duì)grails用戶有點(diǎn)用。

    原文地址:http://grails.group.javaeye.com/group/blog/86666



    My experience with grails is getting richer the longer I use it for web application developing. It's very nice that grails is built on top of spring framework which we can take advantage of. I am not a spring user before but with a help from the nice people at the grails forum I was able to achieve what I want to do.


    Calling a stored procedure from a MySQL database or any other database is simple. First we need a datasource which spring could provide for us. I have the following code place in the resources.xml found in the spring folder in your grails folder.


    <bean id="dataSource" class=" org.apache.commons.dbcp.BasicDataSource ">
    <property name="driverClassName">
    <value>org.hsqldb.jdbcDriver</value>
    </property>
    <property name="url">
    <value>jdbc:hsqldb:hsql://localhost</value>
    </property>
    <property name="username">
    <value>sa</value>
    </property>
    <property name="password">
    <value></value>
    </property>
    </bean>



    I use connection pooling for better performance. In my controller here is how I use the datasource to call a store procedure.


    class MainController {

    def dataSource // using the datasource we define in the spring's resources.xml

    def index = {
    Sql sql = new Sql(dataSource)
    def row = sql.execute("call create_daily_hours(${new Date()+1})")
    }
    }


    That's it! Notice that I am using Groovy SQL instead of Spring JDBCTemplate. It's a lot more friendlier for a beginner.

    Grails really makes everything easy here and provides a lot of flexibility thanks to it's nice integration with spring. From here everything is possible.

    原文地址:http://james-says.blogspot.com/2007/03/grails-little-of-spring-framework.html

    附:
    朝花夕拾——Groovy & Grails
    posted on 2007-06-04 19:39 山風(fēng)小子 閱讀(1887) 評(píng)論(0)  編輯  收藏 所屬分類: Groovy & Grails
    主站蜘蛛池模板: 国产AV无码专区亚洲AWWW| 在线观看91精品国产不卡免费| 美女视频黄频a免费| 国产无限免费观看黄网站| 免费一级毛片不卡在线播放| 亚洲精华国产精华精华液网站| 国产亚洲综合久久| 免费高清在线影片一区| 国产精品亚洲AV三区| 亚洲视频在线免费观看| 亚洲视频一区在线| 一级女人18毛片免费| 亚洲色少妇熟女11p| 国产精品无码一区二区三区免费 | 亚洲AV成人片色在线观看| 美女视频黄的免费视频网页 | 亚洲无人区视频大全| 蜜桃AV无码免费看永久| 狠狠综合久久综合88亚洲| 亚洲精华国产精华精华液| 亚洲国产精品自在拍在线播放 | 色视频在线观看免费| 亚洲日本一区二区一本一道| 免费无码又爽又刺激高潮软件| 日韩免费一区二区三区| 亚洲日韩图片专区第1页| 一区二区三区观看免费中文视频在线播放 | 亚洲另类无码专区丝袜| 国产成人在线免费观看| 中文字幕手机在线免费看电影| 成人a视频片在线观看免费| 亚洲精品福利视频| 怡红院亚洲红怡院在线观看| 亚洲美日韩Av中文字幕无码久久久妻妇 | 99国产精品免费视频观看| 亚洲一区二区三区在线视频| 无码精品一区二区三区免费视频| 伊人久久综在合线亚洲91| 最近新韩国日本免费观看| 鲁死你资源站亚洲av| 国产∨亚洲V天堂无码久久久|