在 Java 应用程序的控制器类中创建新数据库
有人可以告诉我如何在 Java 应用程序的控制器类中创建一个新数据库吗?例如,我能够连接到数据库并保存设置 -
private void saveProps() {
if (dbTypeComboBox.getSelectedItem().toString().contains("racle")) {
this.dbprops.setTypeDB(DBType.ORACLE);
} else if (dbTypeComboBox.getSelectedItem().toString().toLowerCase().contains("ysql")){
this.dbprops.setTypeDB(DBType.MySQL);
}else{
this.dbprops.setTypeDB(DBType.SYBASE);
}
this.dbprops.setHostName(hostTF.getText());
this.dbprops.setPort(portTF.getText());
this.dbprops.setUser(userTF.getText());
this.dbprops.setPass(passwordTF.getText());
this.dbprops.setDbDriver(dbDriverTF.getText());
try {
this.dbprops.setConnection_Timeout(Integer.parseInt(timeOutTF.getText()));
} catch (Exception ex) {
this.dbprops.setConnection_Timeout(10);
}
this.dbprops.setSIDOracle(sidTF.getText());
this.dbprops.setPrefixUserOracle(prefixUserTF.getText());
}
但我需要一种方法来在视图控制器架构的控制器类中创建、编辑或删除数据库。
谢谢。
Can some one show me how to create a new database in the controller class of a Java application? For example, I am able to connect to a database and save the settings -
private void saveProps() {
if (dbTypeComboBox.getSelectedItem().toString().contains("racle")) {
this.dbprops.setTypeDB(DBType.ORACLE);
} else if (dbTypeComboBox.getSelectedItem().toString().toLowerCase().contains("ysql")){
this.dbprops.setTypeDB(DBType.MySQL);
}else{
this.dbprops.setTypeDB(DBType.SYBASE);
}
this.dbprops.setHostName(hostTF.getText());
this.dbprops.setPort(portTF.getText());
this.dbprops.setUser(userTF.getText());
this.dbprops.setPass(passwordTF.getText());
this.dbprops.setDbDriver(dbDriverTF.getText());
try {
this.dbprops.setConnection_Timeout(Integer.parseInt(timeOutTF.getText()));
} catch (Exception ex) {
this.dbprops.setConnection_Timeout(10);
}
this.dbprops.setSIDOracle(sidTF.getText());
this.dbprops.setPrefixUserOracle(prefixUserTF.getText());
}
But I need a method to create, edit or delete a DB in the controller class of the View Controller architecture.
Thank You.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这太含糊和开放了。您需要提出更具体的问题。
作为一般答案,我建议研究诸如休眠之类的技术,因为您想支持多个数据库。甚至可能还使用 Spring 框架 IOC 容器。
This is too vague and open ended. You need to ask more specific questions.
As a general answer I would suggest looking into technologies such as hibernate because you want to support multiple databases. Possibly even with a Spring framework IOC container as well.