开发者

How to execute BACKUP DATABASE query from grails?

开发者 https://www.devze.com 2023-01-14 07:19 出处:网络
I want to backup HSQLDB from grails, Here\'s the c开发者_开发百科ommand BACKUP DATABASE TO \'C:/BACKUP/\' BLOCKING

I want to backup HSQLDB from grails, Here's the c开发者_开发百科ommand BACKUP DATABASE TO 'C:/BACKUP/' BLOCKING But how to do this in GORM where all seems Entity related even executeQuery ?

Thank you for sharing your experience :)


Here's one way that still uses groovy, but not GORM. Since it is not related to a specific object, I wouldn't be concerned that you aren't using GORM. You can of course also drop down into java JDBC directly.

 def conn = new groovy.sql.Sql((java.sql.Connection)

 AH.application.mainContext.sessionFactory.currentSession.connection())

    try
    {
      conn.execute("YOUR SQL STATEMENT")
    }
    catch (Exception e)
    {
      System.out.println "Error " + e.toString()
      System.out.println proc
    }
    conn.close()
0

精彩评论

暂无评论...
验证码 换一张
取 消