Examples of DBConnectionInfo


Examples of org.apache.cayenne.modeler.pref.DBConnectionInfo

    public void setDataSourceKey(String dataSourceKey) {
        this.dataSourceKey = dataSourceKey;

        // update a clone object that will be used to obtain connection...
        DBConnectionInfo currentInfo = (DBConnectionInfo) dataSources.get(dataSourceKey);
        if (currentInfo != null) {
            currentInfo.copyTo(connectionInfo);
        }
        else {
            connectionInfo = new DBConnectionInfo();
        }

        view.getConnectionInfo().setConnectionInfo(connectionInfo);
    }
View Full Code Here

Examples of org.apache.cayenne.modeler.pref.DBConnectionInfo

    /**
     * Tests that the entered information is valid and can be used to open a conneciton.
     * Does not store the open connection.
     */
    public void okAction() {
        DBConnectionInfo info = getConnectionInfo();
        ClassLoadingService classLoader = getApplication().getClassLoadingService();

        // try making an adapter...
        try {
            info.makeAdapter(classLoader);
        }
        catch (Throwable th) {
            reportError("DbAdapter Error", th);
            return;
        }

        // doing connection testing...
        // attempt opening the connection, and close it right away
        try {
            Connection connection = info.makeDataSource(classLoader).getConnection();
            try {
                connection.close();
            }
            catch (SQLException ex) {
                // ignore close error
View Full Code Here

Examples of org.apache.cayenne.modeler.pref.DBConnectionInfo

        // 1.2 migration fix - update data source adapter names
        Iterator it = dataSources.values().iterator();

        final String _12package = "org.objectstyle.cayenne.";
        while (it.hasNext()) {
            DBConnectionInfo info = (DBConnectionInfo) it.next();
            if (info.getDbAdapter() != null && info.getDbAdapter().startsWith(_12package)) {
                info.setDbAdapter("org.apache.cayenne."
                        + info.getDbAdapter().substring(_12package.length()));
                info.getObjectContext().commitChanges();
            }
        }

        if (altDataSourceKey != null
                && !dataSources.containsKey(altDataSourceKey)
View Full Code Here

Examples of org.apache.cayenne.modeler.pref.DBConnectionInfo

        super(getActionName(), application);
    }

    public void performAction(ActionEvent e) {

        DBConnectionInfo nodeInfo = preferredDataSource();
        String nodeKey = preferredDataSourceLabel(nodeInfo);

        DataSourceWizard connectWizard = new DataSourceWizard(
                getProjectController(),
                "Migrate DB Schema: Connect to Database",
View Full Code Here

Examples of org.apache.cayenne.modeler.pref.DBConnectionInfo

     * asynchronously.
     */
    public void performAction(ActionEvent event) {

        // guess node connection
        DBConnectionInfo nodeInfo = preferredDataSource();
        String nodeKey = preferredDataSourceLabel(nodeInfo);

        // connect
        ConnectionWizard connectWizard = new ConnectionWizard(
                getProjectController(),
                "Reengineer DB Schema: Connect to Database",
                nodeKey,
                nodeInfo);

        if (!connectWizard.startupAction()) {
            // canceled
            return;
        }

        Connection connection = connectWizard.getConnection();
        DbAdapter adapter = connectWizard.getAdapter();
        DBConnectionInfo dataSourceInfo = connectWizard.getConnectionInfo();

        // from here pass control to DbLoaderHelper, running it from a thread separate
        // from EventDispatch

        final DbLoaderHelper helper = new DbLoaderHelper(
                getProjectController(),
                connection,
                adapter,
                dataSourceInfo.getUserName());
        Thread th = new Thread(new Runnable() {

            public void run() {
                helper.execute();

View Full Code Here

Examples of org.apache.cayenne.modeler.pref.DBConnectionInfo

     * Overrides superclass to keep an open connection around for the caller's use.
     */
    public void okAction() {
        // build connection and adapter...

        DBConnectionInfo info = getConnectionInfo();
        ClassLoadingService classLoader = getApplication().getClassLoadingService();

        try {
            this.adapter = info.makeAdapter(classLoader);
        }
        catch (Throwable th) {
            reportError("DbAdapter Error", th);
            return;
        }

        try {
            this.connection = info.makeDataSource(classLoader).getConnection();
        }
        catch (Throwable th) {
            reportError("Connection Error", th);
            return;
        }
View Full Code Here

Examples of org.apache.cayenne.modeler.pref.DBConnectionInfo

     * Shows a dialog to create new local DataSource configuration.
     */
    public void newDataSourceAction() {

        DataSourceCreator creatorWizard = new DataSourceCreator(this);
        DBConnectionInfo dataSource = creatorWizard.startupAction();

        if (dataSource != null) {
            dataSourcePreferences.create(creatorWizard.getName(), dataSource);
            dataSources = dataSourcePreferences.getChildrenPreferences();

View Full Code Here

Examples of org.apache.cayenne.modeler.pref.DBConnectionInfo

    public void duplicateDataSourceAction() {
        Object selected = view.getDataSources().getSelectedItem();
        if (selected != null) {
            DataSourceDuplicator wizard = new DataSourceDuplicator(this, selected
                    .toString());
            DBConnectionInfo dataSource = wizard.startupAction();

            if (dataSource != null) {
                dataSourcePreferences.create(wizard.getName(), dataSource);
                dataSources = dataSourcePreferences.getChildrenPreferences();
View Full Code Here

Examples of org.apache.cayenne.modeler.pref.DBConnectionInfo

    /**
     * Tries to establish a DB connection, reporting the status of this operation.
     */
    public void testDataSourceAction() {
        DBConnectionInfo currentDataSource = getConnectionInfo();
        if (currentDataSource == null) {
            return;
        }

        if (currentDataSource.getJdbcDriver() == null) {
            JOptionPane.showMessageDialog(
                    null,
                    "No JDBC Driver specified",
                    "Warning",
                    JOptionPane.WARNING_MESSAGE);
            return;
        }

        if (currentDataSource.getUrl() == null) {
            JOptionPane.showMessageDialog(
                    null,
                    "No Database URL specified",
                    "Warning",
                    JOptionPane.WARNING_MESSAGE);
            return;
        }

        try {

            FileClassLoadingService classLoader = new FileClassLoadingService();

            List<File> oldPathFiles = ((FileClassLoadingService) getApplication()
                    .getClassLoadingService()).getPathFiles();

            Collection details = new ArrayList<String>();
            for (int i = 0; i < oldPathFiles.size(); i++) {
                details.add(oldPathFiles.get(i).getAbsolutePath());
            }

            Preferences classPathPreferences = getApplication().getPreferencesNode(
                    ClasspathPreferences.class,
                    "");
            if (editor.getChangedPreferences().containsKey(classPathPreferences)) {
                Map<String, String> map = editor.getChangedPreferences().get(
                        classPathPreferences);

                Iterator iterator = map.entrySet().iterator();
                while (iterator.hasNext()) {
                    Map.Entry en = (Map.Entry) iterator.next();
                    String key = (String) en.getKey();
                    if (!details.contains(key)) {
                        details.add(key);
                    }
                }
            }

            if (editor.getRemovedPreferences().containsKey(classPathPreferences)) {
                Map<String, String> map = editor.getRemovedPreferences().get(
                        classPathPreferences);

                Iterator iterator = map.entrySet().iterator();
                while (iterator.hasNext()) {
                    Map.Entry en = (Map.Entry) iterator.next();
                    String key = (String) en.getKey();
                    if (details.contains(key)) {
                        details.remove(key);
                    }
                }
            }

            if (details.size() > 0) {

                // transform preference to file...
                Transformer transformer = new Transformer() {

                    public Object transform(Object object) {
                        String pref = (String) object;
                        return new File(pref);
                    }
                };

                classLoader.setPathFiles(CollectionUtils.collect(details, transformer));
            }

            Class<Driver> driverClass = classLoader.loadClass(
                    Driver.class,
                    currentDataSource.getJdbcDriver());
            Driver driver = driverClass.newInstance();

            // connect via Cayenne DriverDataSource - it addresses some driver issues...
            Connection c = new DriverDataSource(
                    driver,
                    currentDataSource.getUrl(),
                    currentDataSource.getUserName(),
                    currentDataSource.getPassword()).getConnection();
            try {
                c.close();
            }
            catch (SQLException e) {
                // i guess we can ignore this...
View Full Code Here

Examples of org.apache.cayenne.modeler.pref.DBConnectionInfo

        this.view = createView();
        this.view.setTitle(title);
        this.altDataSource = altDataSource;
        this.altDataSourceKey = altDataSourceKey;
        this.connectionInfo = new DBConnectionInfo();
       
        initBindings();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.