从 Lotus Notes 数据库获取表名
我正在尝试编写一个程序,通过 NotesSQL 驱动程序将整个 Lotus Notes 数据库转储到文件中。我通过 jdbc:odbc 连接,并且
可以执行选择并从 Lotus Notes 数据库获取数据,
这里是代码
try {
System.out.print("Connecting... ");
Connection con = DriverManager.getConnection("jdbc:odbc:NRC", "UserName", "Passw0rd1337");
System.out.println("OK");
DatabaseMetaData dmd = con.getMetaData();
String[] tableTypes = new String[] {"TABLE", "VIEW"};
ResultSet rs = dmd.getTables(null, null, "%", tableTypes);
ResultSetMetaData rsd = rs.getMetaData();
while (rs.next()) {
for (int i=1; i<=rsd.getColumnCount();i++)
System.out.println(i+" - "+rsd.getColumnName(i) + " - " + rs.getString(1));
}
con.close();
System.out.println("Connection closed");
} catch (Exception e) {
System.out.println(e);
}
有没有更好的方法通过 NotesSQL 连接到 Lotus Notes 数据库?因为使用我的代码我只能得到名称的 null
值...
I'm trying to write a program that would dump a whole lotus notes database to a file via NotesSQL driver. I'm connecting via jdbc:odbc and have
I can execute selects and get data from Lotus notes database
here is the code
try {
System.out.print("Connecting... ");
Connection con = DriverManager.getConnection("jdbc:odbc:NRC", "UserName", "Passw0rd1337");
System.out.println("OK");
DatabaseMetaData dmd = con.getMetaData();
String[] tableTypes = new String[] {"TABLE", "VIEW"};
ResultSet rs = dmd.getTables(null, null, "%", tableTypes);
ResultSetMetaData rsd = rs.getMetaData();
while (rs.next()) {
for (int i=1; i<=rsd.getColumnCount();i++)
System.out.println(i+" - "+rsd.getColumnName(i) + " - " + rs.getString(1));
}
con.close();
System.out.println("Connection closed");
} catch (Exception e) {
System.out.println(e);
}
And is there a better way to connect to Lotus notes databases via NotesSQL? Because with my code i get only null
values for the names...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道您正在尝试使用 JDBC 和 NotesSQL。但是,根据您的需要,使用 Eclipse,您可以通过 Java 本地访问 Notes 数据库,坦率地说,这比尝试使用 JDBC 容易得多,当您在 Domino 中使用 JDBC 时,这有点像圆孔中的方钉子。即使您的主机上没有安装 Lotus Notes,您仍然可以编写和部署 java applet 和 servlet 来获取数据。
不过,您需要获得相关的 Lotus Domino jar。因此,我的建议是 JDBC 的替代方法。
因此,只要您的 Eclipse 项目中有 Lotus Domino jar 文件,您就应该能够从视图中编写任何类型的提取内容,甚至可以在数据库上运行即席搜索。
设置
如果这听起来像您需要走的方向,那么首先,看看使用相关 Notes jar 的 此处。只有几个。 (有时您会读到有关使用 CORBA 和/或 IIOP 的内容。尽量避免这种情况,这只是一个充满伤害的世界)。
示例和代码片段
这篇开发人员作品文章(虽然已经 6 岁了)仍然为 Domino 工作,并且为我所提倡的方法奠定了坚实的基础。该文章首先介绍 NotesFactory 和 Session 类的初始化,以便让您了解 Notes API。有关 NotesFactory 类的更多在线帮助请参见此处。
如果您有可用的 Lotus Notes 客户端,您可以在此处查看代码片段。可以在此处找到通过 Java 视图访问文档的经典示例。
之后,您可以通过此处中的示例轻松访问视图和文档,并向大师(Bob Balaban)学习内存管理此处。
如果您正在处理大量数据或运行 servlet,那么内存管理就很重要,否则不要过分强调它。您可以通过将 Notes 数据库写入公式,然后使用“search" 方法来本机执行查询。
遍历文档或视图?
最简单的方法是通过视图遍历文档和/或使用“getdocumentByKey" 方法来获取集合并对其进行处理。在 Domino 中,“视图”相当于表。您还可以通过 Database.Views property
本机查询
很难找到有关 Notes 本机查询的明确说明,但我设法在网上找到它 < a href="http://www.nissan.gr/help/help85_admin.nsf/2e73cbb2141acefa85256b8700688cea/1fe816b545dde4b28525760b00049128?OpenDocument" rel="noreferrer">此处。
I know you are trying to use JDBC and NotesSQL. But, depending on your needs, and using Eclipse, you can access Notes databases natively via Java, which frankly is alot easier than trying to use JDBC, bit of a square peg in a round hole when you're using JDBC with Domino. Even if you don't have Lotus Notes installed on the host machine you can still write and deploy java applets and servlets to get into the data.
You will need to get the relevant Lotus Domino jar's though. So, my recommendation is an alternative approach to JDBC.
So, providing you have the Lotus Domino jar files in your Eclipse project you should be able to code any kind of extract from a view or even run adhoc searches on a database.
Setup
If this sounds like the direction you need to go, then firstly, have a look at setting up Eclipse with relevant Notes jar's here. There are only a few. (Sometimes you'll read about using CORBA and/or IIOP. Try avoid that, it's just a world of hurt).
Samples and snippets
This developer works article (although 6 years old) still works for Domino and is a sound foundation for the approach I am advocating. That article starts to address the initialization of the NotesFactory and Session classes to get you into the Notes API. More online help here for the NotesFactory class.
If you have a Lotus Notes client available you can have a look through code snippets here. A classic example for accessing documents via Views in Java can be found here.
After that you can easily access Views and documents with examples from here, and learn from the guru, (Bob Balaban), about memory management here.
If you're processing high volumes or running servlets, then memory management is important, otherwise don't stress about it too much. You can execute Native searches on a Notes database by writing it in formula, and then using the "search" methods to execute the query natively.
Iterating through documents or views ?
The easiest approach is to traverse documents via views and/or use "getdocumentByKey" methods to get a collection and work on that. In Domino "Views" are the equivalent of Tables. You can also get a list of Views via the Database.Views property
Native Queries
It's difficult to find definitive instructions on native queries for Notes, but I have managed to find it online here.