如何加入另一个MySQL表在使用主/明细在Netbeans示例表单吗?How to join another MySQL table when using Master/Detail Sample Form in Netbeans?

- 此内容更新于:2014-12-30
主题:

原文:

I am trying to implement an application by using MySQL/JAVA and I found this tool in netbeans to easily create a new form for an existing table. (edit, insert, delete etc.) Is there an easy way to modify the code to join another table to display fields from that table.

Example: I have an employee table that has a foreign key TitleID and another table called Title that has TitleID and TitleName. I want to display TitleName instead of TitleID in the master table employee.

解决方案:
我不认为你会在NetBeans找到类似的。然而,如果您的数据库设计非常简单(如标题示例是真实的),你可以尝试使用可更新视图(更多信息),并把它作为一个表。 在复杂的情况下,你将不得不重写(扩展?)不管你使用的是哪种类数据库访问。但它仍然是应该可以使用任何你已经使用的UI组件。
原文:

I do not think you will find something like that in NetBeans. However, if your DB design is simple enough (i.e. title example is real), you can try to use updatable view (more info) and use it as a table.

In complicated cases you will have to rewrite (extend?) whatever class you are using for DB access. But it is still should be possible to use whatever UI component you have been using.