oracle jdbc jface 向导页面
我想创建一个 jface 向导并收集凭据 - 第 1 页上的密码和用户名,然后在第 2 页上我想显示从 Oracle 数据库获取的列表。
我正在使用 eclipse,并且所有控件都在我想要的地方。在第2页上,我将oracle连接详细信息和sql语句放在wizardpage的createControl方法中。 ,我无法确定这是 Eclipse 问题还是我的代码(我的代码在独立时工作,而不是在向导中工作)
这似乎因找不到类(ojdbc6.jar 包含在我的构建路径中)而失败 当我启动向导页面时会发生这种情况,它可能会执行此操作,因为当时我还没有获得正确的凭据。我在向导页面文档中找不到用于在进入该向导页面时运行内容的方法。有没有一种在入口处运行的方法?
我想连接到数据库以下拉列表来填充表。
干杯
大卫
I want to create a jface wizard and collect credentials as I go along - password and username on page 1 and then on page 2 I want to display a list I get from an oracle database.
I am using eclipse, and have all the controls in the places I want. On page 2 I put the oracle connection details and sql statement in the createControl method of wizardpage. This seems to fail with a class not found (ojdbc6.jar included in my build path) which I can't decide whether this is an eclipse issue or my code (my code works when it is standalone, not in a wizard)
The failure happens when I start the wizardpage, which it probably will do as I havent got the correct credentials at that point. I couldn't find a method in the wizardpage documentation for running stuff when you enter that wizardpage. Is there a method that runs on entry?
I want to connect to the database to pull down a list to populate a table.
Cheers
David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
打开向导时,所有页面都会调用 createControl 方法。您应该仅使用 createControl 来布局 SWT 或 JFace 对象。
您可能希望在第二个页面变得可见时初始化 JDBC 连接。然后您将在页面上加载您的列表。为此,请重写第二页上的 setVisible 方法,如下所示:
这样,当第二页变得可见时,将初始化连接。 setVisible 方法要做的另一件有用的事情是通过在相关控件上调用forceFocus() 将焦点分配给正确的控件。
The createControl method gets called on all pages when the Wizard is opened. You should use createControl only to layout SWT or JFace objects.
You probably want to initialize the JDBC connection when the second page becomes visible. At that point you would then load your list on the page. To do that, override the setVisible method on the second page as follows:
This way the connection will be initialized when the second page becomes visible. Another useful thing to do from the setVisible method is to assign the focus to the right control by calling forceFocus() on the relevant control.