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

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

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

    posts - 431,  comments - 344,  trackbacks - 0
     

    在特殊情況下,grails應用需要調用數據庫的存儲過程,這在grails的官方文檔里邊好像沒有提到過,在jamesblog里介紹如何解決這個問題。
       
    代碼轉貼如下

    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本身沒有提供訪問存儲過程的便捷方法,而groovyGSQL提供了,因此grails可以直接拿過來用了,當然也可以用springJdbcTemplate
     
    希望對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

    posted on 2008-07-18 09:30 周銳 閱讀(599) 評論(0)  編輯  收藏 所屬分類: Groovy&Grails
    主站蜘蛛池模板: 精品国产污污免费网站入口| 国产好大好硬好爽免费不卡| 亚洲Av无码国产情品久久| 黄色三级三级免费看| 亚洲色无码专区在线观看| 国产成人精品免费视频大全麻豆| 日本亚洲色大成网站www久久| 亚洲国产中文v高清在线观看| 久久精品国产这里是免费| 精品国产日韩久久亚洲| 国产亚洲精品成人a v小说| 在线永久看片免费的视频| 黄色毛片免费在线观看| 亚洲图片中文字幕| 亚洲国产成人五月综合网 | 亚洲av成人中文无码专区| 亚洲免费日韩无码系列| av无码国产在线看免费网站| 理论片在线观看免费| 亚洲欧洲精品在线| 免费v片在线观看无遮挡| 亚洲啪啪免费视频| 人与动性xxxxx免费| 亚洲人成人77777在线播放| 亚洲午夜久久久久久噜噜噜| 免费人成在线视频| 久久久精品午夜免费不卡| 国产精品亚洲专区无码牛牛| 亚洲电影唐人社一区二区| 91麻豆国产自产在线观看亚洲 | 在线观看亚洲天天一三视| 在线观看人成网站深夜免费| 无码国产精品一区二区免费3p| 免费一级全黄少妇性色生活片| 亚洲美女大bbbbbbbbb| 亚洲宅男天堂在线观看无病毒| 免费国产高清视频| 大学生美女毛片免费视频| 4444www免费看| 91免费在线视频| eeuss免费天堂影院|