电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

[转载]grails调用存储过程(Grails:-calling-a-stored-procedure)VIP免费

[转载]grails调用存储过程(Grails:-calling-a-stored-procedure)_第1页
1/2
[转载]grails调用存储过程(Grails:-calling-a-stored-procedure)_第2页
2/2
[ 转载 ]grails 调用存储过程( Grails : calling a stored procedure ) 在特殊情况下,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/86666My 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. org.hsqldb.jdbcDriver jdbc:hsqldb:hsql://localhost sa 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 山风小子

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

[转载]grails调用存储过程(Grails:-calling-a-stored-procedure)

您可能关注的文档

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部