Browse Source

REPORT-133908 【fr-fbp回归】DB2 新建存储过程显示数据库连接失败

fbp/merge
Destiny.Lin 4 months ago
parent
commit
2ffd076c07
  1. 4
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  2. 13
      designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java
  3. 18
      designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java
  4. 4
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java
  5. 4
      designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java
  6. 3
      designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java
  7. 3
      designer-realize/src/main/java/com/fanruan/data/ConnectionConfigWrapper.java

4
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java

@ -332,7 +332,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
List<String> authConnections = getHasAuthConnections();
for (String name : authConnections) {
if (ComparatorUtils.equals(selectedDSName, name)) {
return ConnectionRepository.getInstance().getByName(name).getConnection();
return ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(name));
}
}
return null;
@ -442,7 +442,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
boolean connect = false;
com.fr.data.impl.Connection database = null;
try {
database = ConnectionRepository.getInstance().getByName(paras.getDatabaseName()).getConnection();
database = ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(paras.getDatabaseName()));
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage(), e);
}

13
designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java

@ -41,11 +41,20 @@ public class LocalConnectionSource extends BaseConnectionSource {
}
@Override
public void testConnection(ConnectionInfoBean database) throws Exception {
public ConnectionInfoBean getByName(String name) {
try {
return ConnectionInfoBeanHelper.createConnectionInfoBean(name, ConnectionConfigProviderFactory.getConfigProvider().getConnection(name));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public String[] testConnection(ConnectionInfoBean database) throws Exception {
try {
// 暂时这么处理,后续最好拉到外层包装一下
TransmissionEncryptionManager.setTransEncryptionLevel(1);
ConnectionProcessorFactory.testConnectionWithSchemaReturn(database);
return ConnectionProcessorFactory.testConnectionWithSchemaReturn(database);
} catch (DriverNotFoundException e) {
throw new DriverUnExistException();
} finally {

18
designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java

@ -78,13 +78,29 @@ public class ConnectionInfoBeanHelper {
return ans;
}
/**
* 根据bean创建连接
*/
public static Connection createConnection(ConnectionInfoBean infoBean) {
try {
if (JDBCConnectionProcessor.KEY.acceptConnectionTypes().contains(infoBean.getConnectionType())) {
return createJDBCConnection(infoBean);
} else {
return ConnectionProcessorFactory.createConnection(infoBean, true);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return null;
}
}
/**
* 创建数据连接Bean可自定义是否携带密码
*/
public static ConnectionInfoBean createConnectionInfoBean(String name, Connection connection, boolean withPassword) throws Exception {
if (connection instanceof NameDatabaseConnection) {
name = ((NameDatabaseConnection) connection).getName();
connection = ConnectionRepository.getInstance().getByName(name).getConnection();
connection = createConnection(ConnectionRepository.getInstance().getByName(name));
}
if (JDBCConnectionProcessor.KEY.acceptConnections().contains(connection.getClass())) {
ConnectionInfoBean bean = new ConnectionInfoBean();

4
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java

@ -20,6 +20,7 @@ import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane;
import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane.DoubleClickSelectedNodeOnTreeListener;
import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper;
import com.fr.design.data.datapane.sqlpane.SQLEditPane;
import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.data.tabledata.StoreProcedureWorkerListener;
@ -187,8 +188,7 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
}
private boolean isAutoParameterDatabase() {
ConnectionBean bean = ConnectionRepository.getInstance().getByName(connectionTableProcedurePane.getSelectedDatabaseConnnectonName());
Connection connection = bean == null ? null : bean.getConnection();
Connection connection = ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(connectionTableProcedurePane.getSelectedDatabaseConnnectonName()));
return connection != null && ArrayUtils.contains(DRIVERS, connection.getDriver());
}

4
designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java

@ -104,7 +104,7 @@ public class TableViewList extends UIList {
@Override
protected DefaultListModel doInBackground() throws Exception {
Connection datasource = ConnectionRepository.getInstance().getByName(databaseName).getConnection();
Connection datasource = ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(databaseName));
boolean status = false;
int count = 3;
//总共给3次连接的机会
@ -168,7 +168,7 @@ public class TableViewList extends UIList {
*/
private DefaultListModel processDataInAnotherThread(String databaseName, String searchFilter, String... typesFilter) throws Exception {
DefaultListModel defaultListModel = new DefaultListModel();
Connection datasource = ConnectionRepository.getInstance().getByName(databaseName).getConnection();
Connection datasource = ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(databaseName));
if (datasource == null) {
return defaultListModel;
}

3
designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java

@ -15,6 +15,7 @@ import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.ChoosePane;
import com.fr.design.data.datapane.DataBaseItems;
import com.fr.design.data.datapane.VerticalChoosePane;
import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper;
import com.fr.design.data.datapane.preview.PreviewLabel.Previewable;
import com.fr.design.editor.DoubleDeckValueEditorPane;
import com.fr.design.editor.editor.ColumnIndexEditor;
@ -178,7 +179,7 @@ public class DatabaseDictPane extends FurtherBasicBeanPane<DatabaseDictionary> i
if (StringUtils.isBlank(para.getDatabaseName())) {
dbDict.setDatabaseConnection(null);
} else {
Connection connection = ConnectionRepository.getInstance().getByName(para.getDatabaseName()).getConnection();
Connection connection = ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(para.getDatabaseName()));
if (connection != null) {
database = new NameDatabaseConnection(para.getDatabaseName());
dbDict.setDatabaseConnection(database);

3
designer-realize/src/main/java/com/fanruan/data/ConnectionConfigWrapper.java

@ -3,6 +3,7 @@ package com.fanruan.data;
import com.fanruan.config.impl.data.ConnectionConfigProvider;
import com.fanruan.config.impl.data.ConnectionConfigWriter;
import com.fr.data.impl.Connection;
import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper;
import com.fr.file.ConnectionConfig;
import com.fr.log.FineLoggerFactory;
import com.fr.transaction.Configurations;
@ -108,7 +109,7 @@ public class ConnectionConfigWrapper implements ConnectionConfigProvider, Connec
@Override
public @Nullable Connection getConnection(@NotNull String connectionName) {
Connection connection = WorkContext.getCurrent().isLocal() ? ConnectionConfig.getInstance().getConnection(connectionName) : ConnectionRepository.getInstance().getByName(connectionName).getConnection();
Connection connection = WorkContext.getCurrent().isLocal() ? ConnectionConfig.getInstance().getConnection(connectionName) : ConnectionInfoBeanHelper.createConnection(ConnectionRepository.getInstance().getByName(connectionName));;
if (connection != null) {
connection.setConnectionName(connectionName);
}

Loading…
Cancel
Save