我正在尝试使用Liquibase在数据库中创建一些表。
一些背景知识:我在本地h2数据库上执行了相同的changelog.xml文件,并且工作得很顺利。我用squirrel测试了下面的oracle数据库,用户名,密码和驱动程序,并成功连接。所以我很确定我正面临一个liquibase问题。我做了大量的谷歌搜索,并没有在SO或其他任何可以帮助我的地方找到任何东西。
我在命令提示符中输入以下内容:
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
返回了:
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
答案 0 :(得分:10)
我在这里找到答案:http://forum.liquibase.org/topic/message-regarding-an-empty-result-set-for-databasechangeloglock
删除databasechangeloglock表为我解决了这个问题。
答案 1 :(得分:6)
如果 DATABASECHANGELOGLOCK 为空,则始终显示错误。 (我在意外删除此表的记录后出现此问题)。
我发现的解决方案很简单:
只需插入一个 ID = 1,LOCKED = 0,LOCKGRANTED = null,LOCKEDBY = null
的虚拟行就是这样!
答案 2 :(得分:3)
当尝试通过postgresql 10.4使用liquibase时,我们遇到了相同核心异常的问题:
Caused by: liquibase.exception.DatabaseException: Expected single row from
liquibase.statement.core.GetViewDefinitionStatement@1de5f25 but got 0`
对于我们来说,这似乎是我们的jdbc驱动程序有问题。
对我们而言,解决方案是将jdbc驱动程序从9.3-1102-jdbc41升级到9.4-1202-jdbc41。
答案 3 :(得分:1)
就我而言,问题是我曾经使用过
class SignIn extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Material(
child: Padding(
padding: EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
'SignIn Screen',
style: TextStyle(fontSize: 26.0),
),
Padding(
padding: EdgeInsets.only(top: 30.0),
),
TextField(
maxLength: 25,
decoration: InputDecoration(
hintText: 'Enter username',
),
),
TextField(
maxLength: 25,
decoration: InputDecoration(
hintText: 'Enter password',
),
),
RaisedButton(
child: Text('SignIn'),
onPressed: _signIn,
),
],
),
),
);
}
代替
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
对于PostgreSQL 10.6。解决了问题