从 Java 连接到 OLEDB 数据源?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1440900/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Connect to OLEDB data source from Java?
提问by Kevin Day
We are trying to connect to a SQL Server instance used by the ACT CRM system. They have managed to lock things down so it isn't possible to connect to the SQL back-end using ODBC (there is some special utility that will add ODBC support that you can install if you purchase the primo version of the software, but that's just crazy).
我们正在尝试连接到 ACT CRM 系统使用的 SQL Server 实例。他们已经设法将事情锁定,因此无法使用 ODBC 连接到 SQL 后端(有一些特殊的实用程序会添加 ODBC 支持,如果您购买了该软件的 primo 版本,您可以安装该支持,但那是只是疯了)。
The recommended method of connecting to theses databases is using an OLEDB connection.
连接到这些数据库的推荐方法是使用 OLEDB 连接。
Does anyone have any tricks/ideas/etc... for how to make and use an OLEDB connection from Java?
有没有人有任何技巧/想法/等...关于如何从 Java 建立和使用 OLEDB 连接?
This doesn't have to be JDBC if that's not possible. All we really need to do is execute a SELECT query that returns two fields and parse those field values out for each row. I have very little experience with OLEDB, so 'use JACOB' might be a good answer, but I'd appreciate some details on what the COM calls would actually have to be.
如果不可能,这不一定是 JDBC。我们真正需要做的就是执行一个 SELECT 查询,该查询返回两个字段并为每一行解析这些字段值。我对 OLEDB 的经验很少,因此“使用 JACOB”可能是一个很好的答案,但我希望了解有关 COM 调用实际上必须是什么的一些详细信息。
采纳答案by elysch
回答by Ben
That's not your problem. The problem is the way they have locked down the server. Basically on startup it looks for logins other than ACTUSER and removes them.
那不是你的问题。问题是他们锁定服务器的方式。基本上在启动时,它会查找 ACTUSER 以外的登录名并将其删除。
You can unlock it pretty easily though, then you will be able to connect in the usual way.
不过,您可以轻松解锁它,然后您将能够以通常的方式进行连接。
https://serverfault.com/questions/77712/sqlserver-need-to-access-an-act-database-for-data-migration
https://serverfault.com/questions/77712/sqlserver-need-to-access-an-act-database-for-data-migration
I've managed to unlock mine but I forget how... I think I started it in single-user mode then did some funny stuff involving decrypting a stored proc in the master database and editing it to remove that "functionality". That in turn involved using SQLTrace to see what commands ACT was sending.
我设法解锁了我的,但我忘记了如何...我想我是在单用户模式下启动它然后做了一些有趣的事情,包括解密主数据库中的存储过程并编辑它以删除该“功能”。这反过来又涉及使用 SQLTrace 来查看 ACT 发送的命令。
I suggest you ask on Server Fault.
我建议你问服务器故障。
回答by Horcrux7
Java can not access OLEDB directly. You need to do this in another language like C++ or C#. Then you can access via JNI or external process. If you does not want write the native part of JNI self then you can use JACOB how you suggest it. But I think an external process take the request seem be simpler.
Java 不能直接访问 OLEDB。您需要使用另一种语言(如 C++ 或 C#)来执行此操作。然后您可以通过 JNI 或外部进程访问。如果您不想编写 JNI self 的本机部分,那么您可以按照您的建议使用 JACOB。但我认为一个外部处理的请求似乎更简单。
回答by Al.
Two ways to solve this issue.
解决这个问题的两种方法。
- Spawn from java an external proc (c#, c++, etc) that connects to SQLSrv using OLEDB and redirect the stdin, stdout and stderr to your java program.
- Create a C# listener on a particular port and have java pass all the requests via a client to that listener.
- 从 java 生成一个外部 proc(c#、c++ 等),它使用 OLEDB 连接到 SQLSrv 并将 stdin、stdout 和 stderr 重定向到您的 java 程序。
- 在特定端口上创建一个 C# 侦听器,并让 java 通过客户端将所有请求传递给该侦听器。
回答by Al.
Or use: http://uda.openlinksw.com/jdbc/mt/jdbc-sqlserver-mt/They develop all kinds of drivers. I used this company before...
或者使用:http: //uda.openlinksw.com/jdbc/mt/jdbc-sqlserver-mt/他们开发各种驱动。我之前用过这家公司...

