[英]How can I create an ODBC linked table in an Access .mdb using Jackcess?
I'm trying to create ODBC linked table in an Access .mdb using Jackcess. 我正在尝试使用Jackcess在Access .mdb中创建ODBC链接表。
Final String connStr = "ODBC;DRIVER={Sybase ASE ODBC Driver};NA=dbhostname,port;DB=myDbName;UID=myID;PWD=myPass;FILEDSN=path//myDSN.dsn";
Database mdb =Database.create(new File("./test.mdb");
mdb.createLinkedTable("testLinkTable",connStr, "targetTableName");
when I open test.mdb, I can see "testLinkTable", but type of link is "Access Link". 当我打开test.mdb时,我可以看到“testLinkTable”,但链接类型是“Access Link”。 I'm expecting to create "ODBC Link" table in test.mdb.
我期待在test.mdb中创建“ODBC Link”表。
Could somebody kindly show me the right way to accomplish this? 有人可以告诉我正确的方法吗?
It appears that the .createLinkedTable()
method in Jackcess is currently only able to create links to tables in another Access database. 看来
.createLinkedTable()
中的.createLinkedTable()
方法目前只能创建到另一个Access数据库中的表的链接。 I just tested this with Jackcess 2.0.1 and the following code successfully created an Access linked table named [Clients] that points to another Access database: 我刚刚使用Jackcess 2.0.1对此进行了测试,并且以下代码成功创建了一个名为[Clients]的Access链接表,该表指向另一个Access数据库:
Database database = DatabaseBuilder.open(new File("C:\\__tmp\\jTest\\linkTest.accdb"));
String linkedTableLocalName = "Clients";
String linkedTableSource = "C:\\Users\\Public\\Database1.accdb";
String linkedTableRemoteName = "Clients";
database.createLinkedTable(linkedTableLocalName, linkedTableSource, linkedTableRemoteName);
However, this code created a linked table named [dbo_Addresses] that looked like a link to another Access database (not an ODBC linked table as intended) and did not work: 但是,此代码创建了一个名为[dbo_Addresses]的链接表,它看起来像是指向另一个Access数据库的链接(不是预期的ODBC链接表),并且不起作用:
Database database = DatabaseBuilder.open(new File("C:\\__tmp\\jTest\\linkTest.accdb"));
String linkedTableLocalName = "dbo_Addresses";
String linkedTableSource = "ODBC;DSN=myDb;Trusted_Connection=Yes;APP=Microsoft Office 2010;DATABASE=myDb;";
String linkedTableRemoteName = "dbo.Addresses";
database.createLinkedTable(linkedTableLocalName, linkedTableSource, linkedTableRemoteName);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.