You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Dave Alvarado <la...@live.com> on 2015/10/26 20:03:06 UTC

Trouble starting Derby in-memory server using Gradle and Liquibase

Hi,


I'm using Gradle 2.7 and Derby 10.12.1.1.  I would like to use Derby to construct an in-memory database for which I can run unit tests.  I'm not sure the right way to set this up but here is what I'm trying.  I thought including ";create=true" in the URL would automatically launch the server but I guess not because I'm getting a "Error connecting to server localhost on port 1,527 with message Connection refused" error when my LIquibase plugin attempts to write to the db.  Below is what I'm including in my build.gradle script



buildscript {

  repositories {

    mavenCentral()

  }

  dependencies {

    classpath 'mysql:mysql-connector-java:5.1.36'

    classpath 'org.apache.derby:derby:10.12.1.1'

    classpath 'org.apache.derby:derbyclient:10.12.1.1'

    classpath 'org.flywaydb:flyway-gradle-plugin:3.2.1'

  }

}


plugins {

  id "org.liquibase.gradle" version "1.1.1"

}


...



flyway {

    url = 'jdbc:derby://localhost:1527/test;create=true'

    user = 'sa'

}


liquibase {

  activities {

    main {

      File propsFile = new File(liquibasePropertiesFile)

      Properties properties = new Properties()

      properties.load(new FileInputStream(propsFile))

      changeLogFile 'src/main/resources/db.changelog-master.xml'

      url properties['url']

      username properties['username']

      password properties['password']

    }

    test {

      File propsFile = new File(liquibasePropertiesFile)

      Properties properties = new Properties()

      properties.load(new FileInputStream(propsFile))

      changeLogFile 'src/main/resources/db.changelog-master.xml'

        url 'jdbc:derby://localhost:1527/test;create=true'

        username 'sa'

    }

    runList = 'main,test'

  }

}



Here is the exception I'm getting in LIquibase ...


Unexpected error running Liquibase: java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused.


SEVERE 10/26/15 1:34 PM: liquibase: java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused.

liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused.

at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:69)

at liquibase.integration.commandline.Main.doMigration(Main.java:884)

at liquibase.integration.commandline.Main.run(Main.java:175)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)

at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:43)

at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)

at org.liquibase.gradle.LiquibaseTask.runLiquibase(LiquibaseTask.groovy:97)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)



Re: Trouble starting Derby in-memory server using Gradle and Liquibase

Posted by Rick Hillegas <ri...@gmail.com>.
What John says. Please see the Derby Server and Administration Guide for 
more details: http://db.apache.org/derby/docs/10.12/adminguide/index.html

Thanks,
-Rick

On 10/27/15 2:01 AM, John English wrote:
> On 26/10/2015 21:03, Dave Alvarado wrote:
>> *I’m using Gradle 2.7 and Derby 10.12.1.1.  I would like to use Derby to
>> construct an in-memory database for which I can run unit tests.  I’m not
>> sure the right way to set this up but here is what I’m trying.  I
>> thought including “;create=true” in the URL would automatically launch
>> the server but I guess not because I’m getting a “*Error connecting to
>> server localhost on port 1,527 with message Connection refused*”
>> error when my LIquibase plugin attempts to write to the db.  Below is
>> what I’m including in my build.gradle script*
>
> You'll need to start the server as a separate process before you start 
> running your code. Or use an embedded server, which is much simpler, 
> particularly if you only want a transient in-memory DB.


Re: Trouble starting Derby in-memory server using Gradle and Liquibase

Posted by John English <jo...@gmail.com>.
On 26/10/2015 21:03, Dave Alvarado wrote:
> *I’m using Gradle 2.7 and Derby 10.12.1.1.  I would like to use Derby to
> construct an in-memory database for which I can run unit tests.  I’m not
> sure the right way to set this up but here is what I’m trying.  I
> thought including “;create=true” in the URL would automatically launch
> the server but I guess not because I’m getting a “*Error connecting to
> server localhost on port 1,527 with message Connection refused*”
> error when my LIquibase plugin attempts to write to the db.  Below is
> what I’m including in my build.gradle script*

You'll need to start the server as a separate process before you start 
running your code. Or use an embedded server, which is much simpler, 
particularly if you only want a transient in-memory DB.
-- 
John English