我正在尝试使用maven为sql server 2012设置liquibase。我正在使用 sqljdbc4.jar 并尝试使用Windows身份验证连接到sql server。使用Windows身份验证,我还将下面的行包含为VM参数来读取文件 sqljdbc_auth.dll
-Djava.library.path="D:\Microsoft JDBC Driver 4.0 for SQL Server\sqljdbc_4.0\enu\auth\x86"
我无法弄清楚为什么当我在maven中运行liquibase( liquibase:update -PlocalDB -e -X )时,它会挂起并收到此错误:
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.1:update (default-cli) on project Database: Error setting up or running Liquibase: liquibase.exception.DatabaseException: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientConnectionId:47817196-07c1-4fc8-92e2-7e03ca044fcb -> [Help 1]
的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.liquibase</groupId>
<artifactId>Database</artifactId>
<version>1.0</version>
<properties>
<skipTests>true</skipTests>
<jdk-version>1.6</jdk-version>
<sqlserver-version>4.0</sqlserver-version>
<liquibase-version>3.1.1</liquibase-version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${jdk-version}</source>
<target>${jdk-version}</target>
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase-version}</version>
<configuration>
<changeLogFile>src/main/resources/changelogs/changelog-master.xml</changeLogFile>
<driver>${database.driver}</driver>
<url>${database.url}</url>
</configuration>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>localDB</id>
<properties>
<database.driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</database.driver>
<database.url>jdbc:sqlserver://computername:1433;databaseName=Test_Liquibase;integratedSecurity=true</database.url>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>${sqlserver-version}</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase-version}</version>
</dependency>
</dependencies>
编辑来自maven的完整堆栈跟踪
[错误]无法执行目标org.liquibase:liquibase-maven-plugin:3.1.1:update(default-cli)项目数据库:设置或运行Liquibase时出错:liquibase.exception.DatabaseException:com.microsoft .sqlserver.jdbc.SQLServerException:连接重置ClientConnectionId:38797943-7fe8-49e7-8565-5f72dfd6ed1e - &gt; [帮助1] org.apache.maven.lifecycle.LifecycleExecutionException:无法执行目标org.liquibase:liquibase-maven-plugin:3.1.1:update(default-cli)项目数据库:设置或运行Liquibase时出错:liquibase.exception.DatabaseException :com.microsoft.sqlserver.jdbc.SQLServerException:连接重置ClientConnectionId:38797943-7fe8-49e7-8565-5f72dfd6ed1e 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 在org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 在org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) 在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 在org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 在org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在java.lang.reflect.Method.invoke(Method.java:597) 在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 在org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 在org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 在org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 由以下原因引起:org.apache.maven.plugin.MojoExecutionException:设置或运行Liquibase时出错:liquibase.exception.DatabaseException:com.microsoft.sqlserver.jdbc.SQLServerException:Connection reset ClientConnectionId:38797943-7fe8-49e7-8565-5f72dfd6ed1e at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:381) 在org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ......还有19个 引发者:liquibase.exception.DatabaseException:liquibase.exception.DatabaseException:com.microsoft.sqlserver.jdbc.SQLServerException:Connection reset ClientConnectionId:38797943-7fe8-49e7-8565-5f72dfd6ed1e at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:61) at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:330) ......还有21个 引起:liquibase.exception.DatabaseException:com.microsoft.sqlserver.jdbc.SQLServerException:连接重置ClientConnectionId:38797943-7fe8-49e7-8565-5f72dfd6ed1e 在liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:231) at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:141) at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:52) ......还有22个 引起:com.microsoft.sqlserver.jdbc.SQLServerException:连接重置ClientConnectionId:38797943-7fe8-49e7-8565-5f72dfd6ed1e 在com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1654) 在com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1789) 在com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:4838) 在com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:6154) 在com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:6106) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2907) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2234) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.access $ 000(SQLServerConnection.java:41) 在com.microsoft.sqlserver.jdbc.SQLServerConnection $ LogonCommand.doExecute(SQLServerConnection.java:2220) 在com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827) 在com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012) 在liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:223) ......还有24个
答案 0 :(得分:0)
Liquibase似乎试图通过JDBC驱动程序中的“连接重置ClientConnectionId”错误来打开连接并失败。
连接调用只是driverObject.Connect(url, properties)
,其中属性是用户名和密码(如果在maven中指定)。由于您没有指定它们,因此它们应为null。
您是否可以使用您提供的URL正常连接到数据库?它可能是防火墙/网络问题。否则我会怀疑导致问题的Windows身份验证尝试。
答案 1 :(得分:0)
改变maven使用java 7,而不是java 6,Windows身份验证和SQL服务器身份验证工作,我能够连接。 :)