<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  評論-1047  文章-0  trackbacks-0
    ? 在特殊情況下,grails應用需要調用數據庫的存儲過程,這在grails的官方文檔里邊好像沒有提到過,在james的blog里介紹如何解決這個問題。
    ??? 代碼轉貼如下
    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. }??
    ? 需要說明的一些是:grails本身沒有提供訪問存儲過程的便捷方法,而groovy的GSQL提供了,因此grails可以直接拿過來用了,當然也可以用spring的JdbcTemplate。
    ? 希望對grails用戶有點用。

    原文地址: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 山風小子 閱讀(1894) 評論(0)  編輯  收藏 所屬分類: Groovy & Grails
    主站蜘蛛池模板: 亚洲国产精彩中文乱码AV| 9久9久女女免费精品视频在线观看| 国产真实伦在线视频免费观看| 亚洲欧洲日产国产最新| 69视频在线是免费观看| 久久精品国产亚洲av水果派| 最近免费中文在线视频| 亚洲天堂中文字幕在线观看| 免费精品国产自产拍在线观看图片| 亚洲国产福利精品一区二区| 国产91免费视频| 亚洲精品无码成人| 一区二区无码免费视频网站| 在线观看亚洲AV每日更新无码| 国产无遮挡吃胸膜奶免费看视频| 狠狠综合亚洲综合亚洲色| 亚洲色偷偷综合亚洲AV伊人| a视频免费在线观看| 精品亚洲成a人片在线观看| 亚色九九九全国免费视频| 亚洲精品蜜夜内射| 亚洲人午夜射精精品日韩| 中文字幕久精品免费视频 | 国产gav成人免费播放视频| 黄色毛片免费观看| 亚洲春色在线视频| 青春禁区视频在线观看直播免费| 国产精品亚洲精品爽爽| 亚洲国产精品无码久久久不卡| 精品国产sm捆绑最大网免费站| 亚洲精品精华液一区二区| 国产成人高清亚洲| h片在线免费观看| 男女猛烈无遮掩视频免费软件| 久久久久亚洲AV成人无码网站| 无码一区二区三区AV免费| 又粗又长又爽又长黄免费视频| 亚洲性天天干天天摸| 国产亚洲福利一区二区免费看| 鲁丝片一区二区三区免费| 亚洲色偷偷色噜噜狠狠99网|