<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
    主站蜘蛛池模板: 一级做a爱过程免费视频高清| 亚洲国产精品人久久电影| 久久久久亚洲AV无码去区首| 无码中文在线二区免费| 亚洲国产成人精品无码区在线秒播| 久久这里只精品热免费99| 亚洲一区精品无码| 成人免费一区二区三区| 久久亚洲精品中文字幕三区| 三级黄色免费观看| 亚洲AV无码第一区二区三区| 久久久国产精品福利免费| 亚洲一区二区中文| 国产无人区码卡二卡三卡免费| 99久久婷婷国产综合亚洲| 成人免费淫片在线费观看| 日韩亚洲人成网站| 亚洲色欲久久久综合网东京热| 免费精品一区二区三区第35 | 日韩免费高清大片在线 | 亚洲日本VA午夜在线电影| 成在线人永久免费视频播放| 狠狠热精品免费观看| 久久久久久久综合日本亚洲| 91精品手机国产免费| 亚洲综合激情五月色一区| 免费看男女下面日出水视频| 51午夜精品免费视频| 亚洲精品国产手机| 成年私人影院免费视频网站| 免费在线观看一区| 亚洲黄色在线观看| 四虎影视免费永久在线观看| 中文字幕在线免费播放| 亚洲人成免费网站| 亚洲综合色视频在线观看| 一级毛片无遮挡免费全部| 亚洲国产成人片在线观看无码| 日韩免费一区二区三区在线 | a级毛片毛片免费观看久潮喷 | 免费欧洲毛片A级视频无风险|