1 56 package org.objectstyle.cayenne.modeler.dialog.db; 57 58 import java.sql.Connection ; 59 60 import org.objectstyle.cayenne.dba.DbAdapter; 61 import org.objectstyle.cayenne.modeler.ClassLoadingService; 62 import org.objectstyle.cayenne.modeler.pref.DBConnectionInfo; 63 import org.objectstyle.cayenne.modeler.util.CayenneController; 64 65 72 public class ConnectionWizard extends DataSourceWizard { 75 76 protected Connection connection; 77 protected DbAdapter adapter; 78 79 public ConnectionWizard(CayenneController parent, String title, 80 String altDataSourceKey, DBConnectionInfo altDataSource) { 81 super(parent, title, altDataSourceKey, altDataSource); 82 } 83 84 87 public void okAction() { 88 90 DBConnectionInfo info = getConnectionInfo(); 91 ClassLoadingService classLoader = getApplication().getClassLoadingService(); 92 93 try { 94 this.adapter = info.makeAdapter(classLoader); 95 } 96 catch (Throwable th) { 97 reportError("DbAdapter Error", th); 98 return; 99 } 100 101 try { 102 this.connection = info.makeDataSource(classLoader).getConnection(); 103 } 104 catch (Throwable th) { 105 reportError("Connection Error", th); 106 return; 107 } 108 109 canceled = false; 111 view.dispose(); 112 } 113 114 117 public Connection getConnection() { 118 return connection; 119 } 120 121 124 public DbAdapter getAdapter() { 125 return adapter; 126 } 127 } | Popular Tags |