简体   繁体   English

在 Windows Server 2012 上安装 TeamCity 时出现错误“java.library.path 中没有 sqljdbc_auth”

[英]Error "no sqljdbc_auth in java.library.path" installing TeamCity on Windows Server 2012

I am installing TeamCity on a Windows 2012 Server.我正在 Windows 2012 服务器上安装 TeamCity。 I'm at the database connection setup screen but getting this error.我在数据库连接设置屏幕但收到此错误。

"SQL error when doing: Taking a connection from the data source: no sqljdbc_auth in java.library.path" “执行时出现 SQL 错误:从数据源获取连接:java.library.path 中没有 sqljdbc_auth”

I've copied the sqljdbc_auth.dll to the C:\\Windows\\System32 folder and added a system environment variable java.library.path that points to this folder.我已将sqljdbc_auth.dll复制到C:\\Windows\\System32文件夹并添加了一个指向此文件夹的系统环境变量java.library.path

Teamcity installs the 32-bit version even if you're on a 64-bit platform unless you deliberately use 64-bit.即使您在 64 位平台上,Teamcity 也会安装 32 位版本,除非您故意使用 64 位。 So I am just going to give you the 32-bit instructions for using Windows authentication with Teamcity SQL database setup.因此,我将向您提供有关在 Teamcity SQL 数据库设置中使用 Windows 身份验证的 32 位说明。 The instructions are the same for the 64-bit setup, just change x86 to x64 64 位设置的说明相同,只需将 x86 更改为 x64

  1. Create an empty database in SQL server在 SQL Server 中创建一个空数据库
  2. Make sure the Windows account configured on the TeamCity service(s) have access to the database确保在 TeamCity 服务上配置的 Windows 帐户可以访问数据库
  3. Copy sqljdbc42.jar to <TeamCity_data_dir>\\lib\\jdbc\\sqljdbc42.jar将 sqljdbc42.jar 复制到<TeamCity_data_dir>\\lib\\jdbc\\sqljdbc42.jar
  4. Copy auth\\x86\\sqljdbc_auth.dll from the Microsoft download to <TeamCity_data_dir>\\lib\\sqljdbc_auth.dllauth\\x86\\sqljdbc_auth.dll从 Microsoft 下载复制到<TeamCity_data_dir>\\lib\\sqljdbc_auth.dll
  5. Open System > Advanced System Settings > Environment Variables and add a System variable TEAMCITY_SERVER_OPTS set to the value -Djava.library.path=<TeamCity_data_dir>\\lib or run setx TEAMCITY_SERVER_OPTS=-Djava.library.path=<TeamCity_data_dir>\\lib打开系统 > 高级系统设置 > 环境变量并添加一个系统变量 TEAMCITY_SERVER_OPTS 设置为值-Djava.library.path=<TeamCity_data_dir>\\lib或运行setx TEAMCITY_SERVER_OPTS=-Djava.library.path=<TeamCity_data_dir>\\lib
  6. Click OK on all dialogs and restart the Teamcity services.在所有对话框中单击确定并重新启动 Teamcity 服务。

Now you can connect Teamcity to the SQL server using Windows Authentication after which the wizard will create the database.现在您可以使用 Windows 身份验证将 Teamcity 连接到 SQL 服务器,然后向导将创建数据库。

Edit: January 27, 2020编辑:2020 年 1 月 27 日

With the 2019.2.1 update I've had to move the sql_jdbcauth.dll file to <TeamCity_data_dir>\\system\\caches\\jdbc\\native\\windows-i386 This could be just a bug in the upgrade process.对于 2019.2.1 更新,我不得不将 sql_jdbcauth.dll 文件移动到<TeamCity_data_dir>\\system\\caches\\jdbc\\native\\windows-i386这可能只是升级过程中的一个错误。

This这个

http://www.mikeobrien.net/blog/teamcity-sqlserver-integrated-security http://www.mikeobrien.net/blog/teamcity-sqlserver-integrated-security

helped me.帮助过我。

I used the JDBC 4.1 version.我使用了 JDBC 4.1 版本。

I managed to resolve the issue by using SQL Server authentication instead of Windows authentication during the database configuration setup.我设法通过在数据库配置设置期间使用 SQL Server 身份验证而不是 Windows 身份验证来解决该问题。 Not sure why this should have fixed the error as it relates to a Java environment variable, but I can only assume that the error was generated by it's failure to login to the database and for some reason threw an unrelated error instead.不知道为什么这应该修复错误,因为它与 Java 环境变量有关,但我只能假设错误是由于无法登录数据库而产生的,并且由于某种原因引发了一个无关的错误。

This appears to be an error with TeamCity throwing the wrong error message.这似乎是 TeamCity 抛出错误错误消息的错误。 If you get this error, try switching to SQL Server authentication.如果出现此错误,请尝试切换到 SQL Server 身份验证。

如果您在 32 位上运行,您只需将sqljdbc_auth.dll的 x86 版本(从 jdbc 下载)复制到<TeamCityProgramDir>\\bin

You should check your TeamCity server log.您应该检查您的 TeamCity 服务器日志。 Mine (located at c:\\TeamCity\\logs\\teamcity-server.log ) mentions the following:我的(位于c:\\TeamCity\\logs\\teamcity-server.log )提到以下内容:

[2019-03-20 07:54:56,045] INFO - jetbrains.buildServer.STARTUP - Native library sqljdbc_auth.dll was not found under either E:\\BuildServer\\lib\\jdbc\\native\\windows-i386 or E:\\BuildServer\\lib\\jdbc\\native; [2019-03-20 07:54:56,045] 信息 - jetbrains.buildServer.STARTUP - 在 E:\\BuildServer\\lib\\jdbc\\native\\windows-i386 或 E:\\BuildServer\\ 下找不到本机库 sqljdbc_auth.dll lib\\jdbc\\native; will continue looking in sun.boot.library.path and java.library.path.将继续查找 sun.boot.library.path 和 java.library.path。

After putting the sqljdbc_auth.dll library in E:\\BuildServer\\lib\\jdbc\\native\\windows-i386 and restarting the service everything was fine and dandy;sqljdbc_auth.dll库放入E:\\BuildServer\\lib\\jdbc\\native\\windows-i386并重新启动服务后一切正常; without having to meddle with bin folders (they get reset during TC upgrades) or having to define environment variables.无需干预bin文件夹(它们会在 TC 升级期间重置)或定义环境变量。

In my case it didn't worked because there were some files from previous install and version TeamCity isntallation.在我的情况下,它不起作用,因为以前安装的一些文件和版本 TeamCity istallation。 I uninstalled TeamCity, deleted all TeamCity folders and installed again.我卸载了 TeamCity,删除了所有 TeamCity 文件夹并重新安装。 Then it worked like a charm.然后它就像一个魅力。

I was running into this issue today with TeamCity 10.x, with bundled Java, and I wanted to migrate an existing, internal, database to SQL Server.我今天在使用捆绑 Java 的 TeamCity 10.x 时遇到了这个问题,我想将现有的内部数据库迁移到 SQL Server。

  1. Follow Setting up TeamCity with MS SQL Server until you need to setup the JDBC Driver.按照使用 MS SQL Server 设置 TeamCity直到您需要设置 JDBC 驱动程序。
  2. Log into your TeamCity server with the same Windows account you setup SQL Server with.使用设置 SQL Server 所用的相同 Windows 帐户登录到 TeamCity 服务器。
  3. With the current version they say to download the 6.0+ driver, but then reference the 4.x version.他们说使用当前版本下载 6.0+ 驱动程序,然后参考 4.x 版本。 You want the version at Downloads\\Microsoft JDBC Driver 6.2 for SQL Server\\sqljdbc_6.2\\enu\\mssql-jdbc-6.2.2.jre8.jar , and to copy it to C:\\ProgramData\\JetBrains\\TeamCity\\lib\\jdbc\\mssql-jdbc-6.2.2.jre8.jar .您需要Downloads\\Microsoft JDBC Driver 6.2 for SQL Server\\sqljdbc_6.2\\enu\\mssql-jdbc-6.2.2.jre8.jar 中的版本,并将其复制到C:\\ProgramData\\JetBrains\\TeamCity\\lib\\jdbc \\mssql-jdbc-6.2.2.jre8.jar
  4. From that same 6.x driver download, copy Downloads\\Microsoft JDBC Driver 6.2 for SQL Server\\sqljdbc_6.2\\enu\\auth\\x86\\sqljdbc_auth.dll to C:\\ProgramData\\JetBrains\\TeamCity\\lib\\sqljdbc_auth.dll .从相同的 6.x 驱动程序下载,将Downloads\\Microsoft JDBC Driver 6.2 for SQL Server\\sqljdbc_6.2\\enu\\auth\\x86\\sqljdbc_auth.dll复制到C:\\ProgramData\\JetBrains\\TeamCity\\lib\\sqljdbc_auth.dll
  5. Add a new System Environment Variable called TEAMCITY_SERVER_OPTS with the value of -Djava.library.path=C:\\ProgramData\\JetBrains\\TeamCity\\lib .添加名为TEAMCITY_SERVER_OPTS的新系统环境变量,其值为-Djava.library.path=C:\\ProgramData\\JetBrains\\TeamCity\\lib
  6. So that the MaintainDB tool works, add another System Environment Variable called TEAMCITY_MAINTAINDB_OPTS with the same value ( -Djava.library.path=C:\\ProgramData\\JetBrains\\TeamCity\\lib ).为了让MaintainDB 工具正常工作,添加另一个名为TEAMCITY_MAINTAINDB_OPTS系统环境变量,具有相同的值( -Djava.library.path=C:\\ProgramData\\JetBrains\\TeamCity\\lib )。

Now you can run MaintainDB without getting an error about the sqljdbc_auth.dll not being in the JAVA library path.现在您可以运行MaintainDB 而不会出现sqljdbc_auth.dll 不在JAVA 库路径中的错误。

See Creating Backup via maintainDB command-line tool - maintainDB Startup Options for why both environment variables need to be set.请参阅通过维护数据库命令行工具创建备份 - 维护数据库启动选项,了解为什么需要设置这两个环境变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM