简体   繁体   English

在32位和64位环境中具有Windows身份验证的SQLServer连接

[英]SQLServer connection with windows authentification in 32- and 64-bit environments

I have a Java Application which is distributed to a few users. 我有一个Java应用程序,已分发给一些用户。 The application connets to a SQLServer Database using windows authentification. 该应用程序使用Windows身份验证连接到SQLServer数据库。 From several SO-Posts ( SO6938717 , SO17277001 ) I learned that it is common practice to set a path to the needed library in the VM arguments. 从几篇SO帖子( SO6938717SO17277001 )中,我了解到通常的做法是在VM参数中设置所需库的路径。

java -Djava.library.path=/path/to/my/dll -jar /my/classpath/goes/here MainClass java -Djava.library.path = / path / to / my / dll -jar / my / classpath / goes / here MainClass

My Application runs on 32- and 64bit environments, but for every environment there is a specific library with the same name: sqljdbc_auth.dll. 我的应用程序在32位和64位环境上运行,但是对于每个环境,都有一个具有相同名称的特定库:sqljdbc_auth.dll。

I can set two paths as VM arguments: java -Djava.library.path=/auth/x86;/auth/x64 -jar /my/classpath/goes/here MainClass 我可以将两个路径设置为VM参数:java -Djava.library.path = / auth / x86; / auth / x64 -jar / my / classpath / goes / here MainClass

But this doesn't work. 但这是行不通的。 How can I ensure, that windows authentification works in 32- and 64bit environments? 如何确保Windows身份验证在32位和64位环境中工作?

Have a look here: 在这里看看:

possible-values-of-processor-architecture 处理器体系结构的可能值

With this in mind you can distribute your app this way: 考虑到这一点,您可以通过以下方式分发应用程序:

/libs/yourjarfiles.jar
/AMD64/sqljdbc_auth.dll (the 64bit version)
/x86/sqljdbc_auth.dll (the 32 bit version)

And call it using 并使用

java -Djava.library.path=.\%PROCESSOR_ARCHITECTURE%\ -jar /my/classpath/goes/here MainClass

Absolute Path to your install might be a good idea in library-path setting. 在库路径设置中,安装的绝对路径可能是个好主意。

EDIT: Addressing the mentioned concerns for 32bit Java on 64bit host 编辑:解决了在64位主机上对32位Java提到的问题

Helper-Class: Architecture.java 助手类:Architecture.java

public class Architecture {    
    public static void main(String[] args) {
        System.out.print(System.getProperty("os.arch"));
    }   
}

CMD to start your program CMD启动程序

@ECHO OFF
for /f %%i in ('java -classpath /my/classpath/goes/here/ Architecture') do set JAVA_ARCH=%%i
java -Djava.library.path=path/to/dlls/%JAVA_ARCH%/ -cp /my/classpath/goes/here MainClass

You'd have to name your directories like this to match possible os.arch values: 您必须像这样命名目录,以匹配可能的os.arch值:

/x86  - 32 bit DLL goes here
/amd64  - 64 bit DLL goes here

I guess if you'd know the path for the libraries you could even append that path based on os.arch System property at runtime of MainClass . 我想,如果你想知道库基础上,你甚至可以追加一条路径的路径os.arch在运行时系统属性MainClass

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

相关问题 如何安装自更新的32位和64位Java? - How do I install self-updating 32- and 64-bit Java? 在Windows 64位平台上安装32位JRE - Install a 32-bit JRE on Windows 64-bit platform Solr - 在Windows 7 64位上使用64位Java,而不是32位Java - Solr - use 64-bit Java, not 32-bit Java on Windows 7 64-bit 与64位Windows中的Access数据库的ODBC连接 - ODBC connection to Access database in 64-bit Windows 这是32位还是64位JVM? - Is this is a 32-bit or 64-bit JVM? 通过Google Web Toolkit检测64位或32位Windows - Detect 64-bit or 32-bit Windows from Google Web Toolkit 在Windows 10 64位系统上,我应将哪个版本的GeckoDriver与Firefox 32位一起使用? - Which version of GeckoDriver should I use with Firefox 32-bit on a Windows 10 64-bit system? 无法在32位操作系统上运行NetBeans(在64位Windows 10上)中创建的.exe - Unable to run .exe created in NetBeans(on 64-bit Windows 10) on 32-bit OS 32 位和 64 位 Windows 服务器上 JVM 的最大堆大小 - Maximum heap size for JVM on a 32-bit and 64-bit windows server 哪些Java内存探查器应用程序可以在Windows 7 64位和Java 1.4 32位上运行? - What Java memory profiler applications will work on Windows 7 64-bit with Java 1.4 32-bit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM