I am trying to create a few tables in a DB using Liquibase.
Some background: I executed the same changelog.xml file on a local h2 database and it worked succussfully. And I tested the below oracle database, username, password and driver with squirrel and it connected successfully. So I'm fairly certain that I am facing a liquibase problem. I did extensive google-ing and did not find anything on SO or anywhere else that could helped me.
I entered the following into the command prompt:
C:\>java -jar liquibase-core-2.0.5.jar --driver=oracle.jdbc.OracleDriver
--classpath=ojdbc6-11.2.0.3.0.jar --changeLogFile=changelog.xml
--url="jdbc:oracle:thin:@myDatabase"
--username=myUsername --password=myPassword --logLevel=debug update
Which returned:
DEBUG 9/30/13 3:09 PM:liquibase: Unable to load/access Apache Derby driver class
to check version
DEBUG 9/30/13 3:09 PM:liquibase: Connected to myUsername@jdbc:oracle:thin:@myDatabase
DEBUG 9/30/13 3:10 PM:liquibase: Executing QUERY database command: SELECT LOCKED
FROM DATABASECHANGELOGLOCK WHERE ID=1 FOR UPDATE
Liquibase Update Failed: Empty result set, expected one row
SEVERE 9/30/13 3:10 PM:liquibase: Empty result set, expected one row
liquibase.exception.LockException: liquibase.exception.DatabaseException: Empty
result set, expected one row
at liquibase.lockservice.LockService.acquireLock(LockService.java:121)
at liquibase.lockservice.LockService.waitForLock(LockService.java:61)
at liquibase.Liquibase.update(Liquibase.java:102)
at liquibase.integration.commandline.Main.doMigration(Main.java:825)
at liquibase.integration.commandline.Main.main(Main.java:134)
Caused by: liquibase.exception.DatabaseException: Empty result set, expected one
row
at liquibase.util.JdbcUtils.requiredSingleResult(JdbcUtils.java:124)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:
159)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:
167)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:
163)
at liquibase.lockservice.LockService.acquireLock(LockService.java:96)
... 4 more
if your DATABASECHANGELOGLOCK is empty, the error will always appear. (I had this problem after accidentally remove the records of this table).
The solution I found was simple:
just insert a dummy row with ID=1, LOCKED=0, LOCKGRANTED=null, LOCKEDBY=null
That's it!
In my case the problem was that I had used
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
instead of
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
</dependency>
for PostgreSQL 10.6. That solved the problem
I found the answer here: https://forum.liquibase.org/t/message-regarding-an-empty-result-set-for-databasechangeloglock/1487/2
Deleting the databasechangeloglock table solved it for me.
We have experienced a problem with the same core exception when trying to use liquibase using postgresql 10.4:
Caused by: liquibase.exception.DatabaseException: Expected single row from
liquibase.statement.core.GetViewDefinitionStatement@1de5f25 but got 0`
It seemed that for us it was a problem with our jdbc driver.
The solution for us was to upgrade the jdbc driver from 9.3-1102-jdbc41 to 9.4-1202-jdbc41.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With