开发者

Create a new database in the controller class of a Java application

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.开发者_Go百科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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜