You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jochen Theodorou (JIRA)" <ji...@apache.org> on 2016/04/16 10:07:25 UTC

[jira] [Updated] (GROOVY-7817) Rewrite all our sql tutorials to use datasource

     [ https://issues.apache.org/jira/browse/GROOVY-7817?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jochen Theodorou updated GROOVY-7817:
-------------------------------------
    Description: 
In JDK9 using the system loader is not going to work any longer with @Grab. This imposes a problem for scripts in our tutorials, which demo database usage. Since changing the database driver access mechanism to use the loader of the Groovy runtime instead of the system loader is not solving the problem I suggest to really update that old java 1.2 usage of jdbc and migrate all our scripts to datasources.

As an example of datasource usage:
{code:Java}
@Grab(group='com.h2database', module='h2', version='1.3.168')
import groovy.sql.Sql
import org.h2.jdbcx.JdbcDataSource;
def ds = new JdbcDataSource(URL: "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", user: "sa", password: "sa");
def sql = Sql.newInstance(ds)
sql.execute '''
     create table PROJECT (
         id integer not null,
         name varchar(50),
         url varchar(100),
     )
 '''
def params = [10, 'Groovy', 'http://groovy.codehaus.org']
sql.execute 'insert into PROJECT (id, name, url) values (?, ?, ?)', params
println 'Some GR8 projects:'
sql.eachRow('select * from PROJECT') { row ->
    println "${row.name.padRight(10)} ($row.url)"
}
{code}


  was:In JDK9 using the system loader is not going to work any longer with @Grab. This imposes a problem for scripts in our tutorials, which demo database usage. Since changing the database driver access mechanism to use the loader of the Groovy runtime instead of the system loader is not solving the problem I suggest to really update that old java 1.2 usage of jdbc and migrate all our scripts to datasources


> Rewrite all our sql tutorials to use datasource
> -----------------------------------------------
>
>                 Key: GROOVY-7817
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7817
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Jochen Theodorou
>              Labels: JDK9
>
> In JDK9 using the system loader is not going to work any longer with @Grab. This imposes a problem for scripts in our tutorials, which demo database usage. Since changing the database driver access mechanism to use the loader of the Groovy runtime instead of the system loader is not solving the problem I suggest to really update that old java 1.2 usage of jdbc and migrate all our scripts to datasources.
> As an example of datasource usage:
> {code:Java}
> @Grab(group='com.h2database', module='h2', version='1.3.168')
> import groovy.sql.Sql
> import org.h2.jdbcx.JdbcDataSource;
> def ds = new JdbcDataSource(URL: "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", user: "sa", password: "sa");
> def sql = Sql.newInstance(ds)
> sql.execute '''
>      create table PROJECT (
>          id integer not null,
>          name varchar(50),
>          url varchar(100),
>      )
>  '''
> def params = [10, 'Groovy', 'http://groovy.codehaus.org']
> sql.execute 'insert into PROJECT (id, name, url) values (?, ?, ?)', params
> println 'Some GR8 projects:'
> sql.eachRow('select * from PROJECT') { row ->
>     println "${row.name.padRight(10)} ($row.url)"
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)