1 / 107
文档名称:

东尚观湖09年整合推广方案.ppt

格式:ppt   大小:5,161KB   页数:107页
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

东尚观湖09年整合推广方案.ppt

上传人:lizhencai0920 2018/6/25 文件大小:5.04 MB

下载得到文件列表

东尚观湖09年整合推广方案.ppt

相关文档

文档介绍

文档介绍:[转载]grails调用存储过程(Grails : calling a stored procedure)
  在特殊情况下,grails应用需要调用数据库的存储过程,这在grails的官方文档里边好像没有提到过,在james的blog里介绍如何解决这个问题。
    代码转贴如下
java 代码
 
class MainController {  
  
  def dataSource // using the datasource we define in the spring's   
  
  def index = {  
      Sql sql = new Sql(dataSource)  
      def row = ("call create_daily_hours(${new Date()+1})")  
  }  
}  
  需要说明的一些是:grails本身没有提供访问存储过程的便捷方法,而groovy的GSQL提供了,因此grails可以直接拿过来用了,当然也可以用spring的JdbcTemplate。
  希望对grails用户有点用。
原文地址:./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 found in the spring folder in your grails folder.
<bean id="dataSource" class=" ">
<property name="driverClassName">
<.</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
def index = {
Sql sql = new Sql(dataSource)
def row = ("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 ev