Browse Source

REPORT-114392 FR-FBP版本本地设计适配 修复数据连接

mss/2.0
Destiny.Lin 4 months ago
parent
commit
229e00c9a7
  1. 6
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  2. 86
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java
  3. 22
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  4. 5
      designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java
  5. 124
      designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java
  6. 2
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  7. 10
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataWrapper.java
  8. 8
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java
  9. 3
      designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java

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

@ -14,6 +14,7 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.RefreshLabel.Refreshable; import com.fr.design.data.datapane.RefreshLabel.Refreshable;
import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper;
import com.fr.design.data.datapane.preview.PreviewLabel; import com.fr.design.data.datapane.preview.PreviewLabel;
import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; import com.fr.design.data.datapane.preview.PreviewLabel.Previewable;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
@ -39,6 +40,7 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.connection.DBConnectAuth; import com.fr.workspace.server.connection.DBConnectAuth;
import com.fr.workspace.server.repository.connection.ConnectionRepository;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -442,8 +444,10 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
return TableData.EMPTY_TABLEDATA; return TableData.EMPTY_TABLEDATA;
} }
try { try {
connect = DataOperator.getInstance().testConnection(database); ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(database));
connect = true;
} catch (Exception ignored) { } catch (Exception ignored) {
connect= false;
} }
if (!connect) { if (!connect) {
DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); DesignerFrame designerFrame = DesignerContext.getDesignerFrame();

86
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

@ -24,6 +24,7 @@ import com.fr.decision.webservice.v10.datasource.connection.processor.impl.Conne
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDBCConnectionProcessor; import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDBCConnectionProcessor;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.data.MapCompareUtils; import com.fr.design.data.MapCompareUtils;
import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.fun.ConnectionProvider; import com.fr.design.fun.ConnectionProvider;
import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.JListControlPane;
@ -74,7 +75,6 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
private final HashMap<String, String> renameMap = new HashMap<>(); private final HashMap<String, String> renameMap = new HashMap<>();
private final Map<String, Connection> populatedConnectionsSnapshot = new LinkedHashMap<>(); private final Map<String, Connection> populatedConnectionsSnapshot = new LinkedHashMap<>();
private static List<String> supportedDatabaseTypes = new ArrayList<>(); private static List<String> supportedDatabaseTypes = new ArrayList<>();
private static ObjectMapper objectMapper = new ObjectMapper();
public ConnectionListPane() { public ConnectionListPane() {
renameMap.clear(); renameMap.clear();
@ -245,11 +245,11 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
removedConnNames.add(s); removedConnNames.add(s);
break; break;
case ADDED: case ADDED:
addConnections.add(createConnectionInfoBean(s, connection)); addConnections.add(ConnectionInfoBeanHelper.createConnectionInfoBean(s, connection, true));
validConnection.add(connection); validConnection.add(connection);
break; break;
case UPDATED: case UPDATED:
updateConnection.add(createConnectionInfoBean(s, connection)); updateConnection.add(ConnectionInfoBeanHelper.createConnectionInfoBean(s, connection, true));
validConnection.add(connection); validConnection.add(connection);
break; break;
default: default:
@ -285,8 +285,8 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
return connection instanceof JDBCDatabaseConnection || connection instanceof JNDIDatabaseConnection; return connection instanceof JDBCDatabaseConnection || connection instanceof JNDIDatabaseConnection;
} }
}); });
/// 先不管
this.validateDatabaseType(validConnection); //this.validateDatabaseType(validConnection);
this.alterConnections(addConnections, removedConnNames, updateConnection); this.alterConnections(addConnections, removedConnNames, updateConnection);
} }
@ -333,19 +333,6 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
return false; return false;
} }
private ConnectionInfoBean createConnectionInfoBean(String name, Connection connection) throws Exception {
if (JDBCConnectionProcessor.KEY.acceptConnections().contains(connection.getClass())) {
ConnectionInfoBean bean = new ConnectionInfoBean();
bean.setConnectionData(objectMapper.writeValueAsString(convertToJDBCConnectionBean(connection, true)));
bean.setConnectionType(JDBCConnectionProcessor.CONNECTION_TYPE);
bean.setConnectionType(JDBCConnectionProcessor.KEY.getConnectionType(connection));
bean.setConnectionName(name);
bean.setCreator(connection.getCreator());
return bean;
} else {
return ConnectionProcessorFactory.createConnectionInfoBean(name, connection);
}
}
private void alterConnections(List<ConnectionInfoBean> addConnections, List<String> removedConnNames, List<ConnectionInfoBean> updateConnection) { private void alterConnections(List<ConnectionInfoBean> addConnections, List<String> removedConnNames, List<ConnectionInfoBean> updateConnection) {
@ -389,7 +376,11 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
} }
public static void showDialog(Window parent) { public static void showDialog(Window parent) {
Map<String, Connection> connectionMap = ConnectionConfigProviderFactory.getConfigProvider().getConnections(); List<ConnectionBean> beans = ConnectionRepository.getInstance().getAll();
Map<String, Connection> connectionMap = new HashMap<>();
for (ConnectionBean bean : beans) {
connectionMap.put(bean.getName(), bean.getConnection());
}
final ConnectionManagerPane connectionManagerPane = new ConnectionManagerPane() { final ConnectionManagerPane connectionManagerPane = new ConnectionManagerPane() {
@Override @Override
public void complete() { public void complete() {
@ -415,61 +406,4 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
} }
} }
/**
* jdbc的特殊处理
*/
private JDBCConnectionBean convertToJDBCConnectionBean(Connection connection, boolean withPassword) {
JDBCDatabaseConnection jdbcConnection = (JDBCDatabaseConnection) connection;
JDBCConnectionBean jdbcConnectionBean = new JDBCConnectionBean();
DBCPConnectionPoolAttr poolAttr = new DBCPConnectionPoolAttr();
try {
poolAttr = (DBCPConnectionPoolAttr) jdbcConnection.getDbcpAttr().clone();
} catch (CloneNotSupportedException ignore) {
}
poolAttr.setValidationQuery(TransmissionTool.encrypt(poolAttr.getValidationQuery()));
KerberosAuthentication kerberosAuthentication = null;
if (jdbcConnection.getAuthentication().type() == AuthenticationType.KERBEROS) {
//获取数据连接信息的时候,做一下兼容处理(兼容旧的kerberos形式)
KerberosUtils.compatibilityProcess(((KerberosAuthentication) jdbcConnection.getAuthentication()));
kerberosAuthentication = ((KerberosAuthentication) jdbcConnection.getAuthentication());
}
//因为设计器创建连接时database属性为空,所以这里直接取数据库保存的fetchSize值,默认值为-1
return jdbcConnectionBean
.newCharsetName(jdbcConnection.getNewCharsetName())
.originalCharsetName(jdbcConnection.getOriginalCharsetName())
.database(jdbcConnection.getDatabase())
.user(jdbcConnection.getUser())
.driver(jdbcConnection.getDriver())
// 关键中的关键,由设计器发出的请求如果要携带密码,不能传明文,必须必须必须传加密后的密码
.password(withPassword ? TransmissionEncryptors.getInstance().encrypt(jdbcConnection.getPassword()) : DecisionServiceConstants.DEFAULT_PASSWORD)
.schema(jdbcConnection.getSchema())
.url(jdbcConnection.getURL())
.creator(jdbcConnection.getCreator())
.source(jdbcConnection.getDriverSource())
.connectionPoolAttr(poolAttr.create())
.authType(kerberosAuthentication != null ? "kerberos" : StringUtils.EMPTY)
.principal(kerberosAuthentication != null ? kerberosAuthentication.getPrincipal() : StringUtils.EMPTY)
.keyPath(kerberosAuthentication != null ? kerberosAuthentication.getKeyPath() : StringUtils.EMPTY)
.krb5Path(kerberosAuthentication != null ? KerberosUtils.getKrb5Path(kerberosAuthentication.getKeyPath(), kerberosAuthentication.getPrincipal()) : StringUtils.EMPTY)
.useJaas(jdbcConnection.getAuthentication().type() == AuthenticationType.KERBEROS && ((KerberosAuthentication) jdbcConnection.getAuthentication()).getUseJaas())
.fetchSize(jdbcConnection.getFetchSize()).identity(connection.getIdentity())
.sshType(jdbcConnection.getSsh().getSshType().toString())
.sshIp(((BaseSsh) jdbcConnection.getSsh()).getIp())
.usingSsh(jdbcConnection.getSsh().isUsingSsh())
.sshUser(((BaseSsh) jdbcConnection.getSsh()).getUser())
.sshPort(((BaseSsh) jdbcConnection.getSsh()).getPort())
.redirectPort(jdbcConnection.getSsh().getRedirectPort())
.redirectIp((jdbcConnection.getSsh()).getRedirectIp())
.sshTimeOut(((BaseSsh) jdbcConnection.getSsh()).getTimeOut())
.sshSecret(withPassword ? ((BaseSsh) jdbcConnection.getSsh()).getSecret() : DecisionServiceConstants.DEFAULT_PASSWORD)
.sshPrivateKeyPath(jdbcConnection.getSsh().getSshType() == SshType.KEY ? ((KeyVerifySsh) jdbcConnection.getSsh()).getPrivateKeyPath() : StringUtils.EMPTY)
.usingSsl((jdbcConnection.getSsl()).isUsingSsl())
.sslType(jdbcConnection.getSsl().getSslType().toString())
.sslClientCertificate(((BaseSsl) jdbcConnection.getSsl()).getClientCertificate())
.sslClientPrivateKey(((BaseSsl) jdbcConnection.getSsl()).getClientPrivateKey())
.caCertificate(((BaseSsl) jdbcConnection.getSsl()).getCaCertificate())
.properties(jdbcConnection.getProperties())
.verifyCa(jdbcConnection.getSsl().getSslType() == SslType.NORMAL && ((NormalSsl) jdbcConnection.getSsl()).isVerifyCa());
}
} }

22
designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java

@ -14,6 +14,7 @@ import com.fr.data.solution.entity.DriverPage;
import com.fr.data.solution.processor.ClassNotFoundExceptionSolutionProcessor; import com.fr.data.solution.processor.ClassNotFoundExceptionSolutionProcessor;
import com.fr.data.solution.processor.SolutionProcessor; import com.fr.data.solution.processor.SolutionProcessor;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
@ -29,6 +30,7 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.repository.connection.ConnectionRepository;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
@ -429,25 +431,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
// 返回连接结果 // 返回连接结果
DriverPage.updateCache(); DriverPage.updateCache();
final Exception[] exception = new Exception[1]; final Exception[] exception = new Exception[1];
WorkContext.getCurrent().get(DataOperatorProvider.class, new ExceptionHandler() { ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(database));
@Override
public Object callHandler(RPCInvokerExceptionInfo exceptionInfo) {
// 正常调用发生的异常也会被捕获,因此需要对异常类型进行判断,如果是NoSuchMethodException 就要去调用 testConnection
// 如果不是 NoSuchMethodException 保存下异常上下文
// 两种情况下异常都需要抛出
if (exceptionInfo.getException() instanceof NoSuchMethodException) {
if (!WorkContext.getCurrent().get(DataOperatorProvider.class).testConnection(database)) {
exception[0] = new Exception(Toolkit.i18nText("Fine-Design_Description_Of_Test_Connection"));
}
} else {
exception[0] = exceptionInfo.getException();
}
return null;
}
}).testConnectionWithException(database);
if (exception[0] != null) {
throw exception[0];
}
return null; return null;
} }

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

@ -18,6 +18,11 @@ import java.sql.SQLException;
*/ */
public class LocalConnectionSource extends BaseConnectionSource { public class LocalConnectionSource extends BaseConnectionSource {
@Override
public void testConnection(ConnectionInfoBean database) throws Exception {
dataOperator.testConnectionWithException(ConnectionProcessorFactory.createConnection(database));
}
@Override @Override
public void add(ConnectionInfoBean bean) throws Exception { public void add(ConnectionInfoBean bean) throws Exception {
Connection connection = ConnectionProcessorFactory.createConnection(bean); Connection connection = ConnectionProcessorFactory.createConnection(bean);

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

@ -0,0 +1,124 @@
package com.fr.design.data.datapane.preview;
import com.fr.data.auth.AuthenticationType;
import com.fr.data.auth.kerberos.KerberosAuthentication;
import com.fr.data.auth.kerberos.KerberosUtils;
import com.fr.data.impl.Connection;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.pool.DBCPConnectionPoolAttr;
import com.fr.data.security.ssh.BaseSsh;
import com.fr.data.security.ssh.SshType;
import com.fr.data.security.ssh.impl.KeyVerifySsh;
import com.fr.data.security.ssl.BaseSsl;
import com.fr.data.security.ssl.SslType;
import com.fr.data.security.ssl.impl.NormalSsl;
import com.fr.decision.privilege.TransmissionTool;
import com.fr.decision.webservice.bean.datasource.ConnectionInfoBean;
import com.fr.decision.webservice.bean.datasource.JDBCConnectionBean;
import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionProcessorFactory;
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDBCConnectionProcessor;
import com.fr.security.encryption.transmission.TransmissionEncryptors;
import com.fr.stable.StringUtils;
import com.fr.third.fasterxml.jackson.databind.ObjectMapper;
/**
* 数据连接传输工具类
*
* @author Destiny.Lin
* @since 11.0
* Created on 2024/7/25
*/
public class ConnectionInfoBeanHelper {
private static ObjectMapper objectMapper = new ObjectMapper();
/**
* 创建数据连接Bean可自定义是否携带密码
*/
public static ConnectionInfoBean createConnectionInfoBean(String name, Connection connection, boolean withPassword) throws Exception {
if (JDBCConnectionProcessor.KEY.acceptConnections().contains(connection.getClass())) {
ConnectionInfoBean bean = new ConnectionInfoBean();
bean.setConnectionData(objectMapper.writeValueAsString(convertToJDBCConnectionBean(connection, withPassword)));
bean.setConnectionType(JDBCConnectionProcessor.CONNECTION_TYPE);
bean.setConnectionType(JDBCConnectionProcessor.KEY.getConnectionType(connection));
bean.setConnectionName(name);
bean.setCreator(connection.getCreator());
return bean;
} else {
return ConnectionProcessorFactory.createConnectionInfoBean(name, connection);
}
}
/**
* 创建数据连接Bean默认携带密码
*/
public static ConnectionInfoBean createConnectionInfoBean(String name, Connection connection) throws Exception {
return createConnectionInfoBean(name, connection, true);
}
/**
* 创建数据连接bean
*/
public static ConnectionInfoBean createConnectionInfoBean(Connection connection) throws Exception {
return createConnectionInfoBean(connection.getConnectionName(), connection, true);
}
/**
* jdbc的特殊处理
*/
private static JDBCConnectionBean convertToJDBCConnectionBean(Connection connection, boolean withPassword) {
JDBCDatabaseConnection jdbcConnection = (JDBCDatabaseConnection) connection;
JDBCConnectionBean jdbcConnectionBean = new JDBCConnectionBean();
DBCPConnectionPoolAttr poolAttr = new DBCPConnectionPoolAttr();
try {
poolAttr = (DBCPConnectionPoolAttr) jdbcConnection.getDbcpAttr().clone();
} catch (CloneNotSupportedException ignore) {
}
poolAttr.setValidationQuery(TransmissionTool.encrypt(poolAttr.getValidationQuery()));
KerberosAuthentication kerberosAuthentication = null;
if (jdbcConnection.getAuthentication().type() == AuthenticationType.KERBEROS) {
//获取数据连接信息的时候,做一下兼容处理(兼容旧的kerberos形式)
KerberosUtils.compatibilityProcess(((KerberosAuthentication) jdbcConnection.getAuthentication()));
kerberosAuthentication = ((KerberosAuthentication) jdbcConnection.getAuthentication());
}
//因为设计器创建连接时database属性为空,所以这里直接取数据库保存的fetchSize值,默认值为-1
return jdbcConnectionBean
.newCharsetName(jdbcConnection.getNewCharsetName())
.originalCharsetName(jdbcConnection.getOriginalCharsetName())
.database(jdbcConnection.getDatabase())
.user(jdbcConnection.getUser())
.driver(jdbcConnection.getDriver())
// 关键中的关键,由设计器发出的请求如果要携带密码,不能传明文,必须必须必须传加密后的密码
.password(withPassword ? TransmissionEncryptors.getInstance().encrypt(jdbcConnection.getPassword()) : DecisionServiceConstants.DEFAULT_PASSWORD)
.schema(jdbcConnection.getSchema())
.url(jdbcConnection.getURL())
.creator(jdbcConnection.getCreator())
.source(jdbcConnection.getDriverSource())
.connectionPoolAttr(poolAttr.create())
.authType(kerberosAuthentication != null ? "kerberos" : StringUtils.EMPTY)
.principal(kerberosAuthentication != null ? kerberosAuthentication.getPrincipal() : StringUtils.EMPTY)
.keyPath(kerberosAuthentication != null ? kerberosAuthentication.getKeyPath() : StringUtils.EMPTY)
.krb5Path(kerberosAuthentication != null ? KerberosUtils.getKrb5Path(kerberosAuthentication.getKeyPath(), kerberosAuthentication.getPrincipal()) : StringUtils.EMPTY)
.useJaas(jdbcConnection.getAuthentication().type() == AuthenticationType.KERBEROS && ((KerberosAuthentication) jdbcConnection.getAuthentication()).getUseJaas())
.fetchSize(jdbcConnection.getFetchSize()).identity(connection.getIdentity())
.sshType(jdbcConnection.getSsh().getSshType().toString())
.sshIp(((BaseSsh) jdbcConnection.getSsh()).getIp())
.usingSsh(jdbcConnection.getSsh().isUsingSsh())
.sshUser(((BaseSsh) jdbcConnection.getSsh()).getUser())
.sshPort(((BaseSsh) jdbcConnection.getSsh()).getPort())
.redirectPort(jdbcConnection.getSsh().getRedirectPort())
.redirectIp((jdbcConnection.getSsh()).getRedirectIp())
.sshTimeOut(((BaseSsh) jdbcConnection.getSsh()).getTimeOut())
.sshSecret(withPassword ? ((BaseSsh) jdbcConnection.getSsh()).getSecret() : DecisionServiceConstants.DEFAULT_PASSWORD)
.sshPrivateKeyPath(jdbcConnection.getSsh().getSshType() == SshType.KEY ? ((KeyVerifySsh) jdbcConnection.getSsh()).getPrivateKeyPath() : StringUtils.EMPTY)
.usingSsl((jdbcConnection.getSsl()).isUsingSsl())
.sslType(jdbcConnection.getSsl().getSslType().toString())
.sslClientCertificate(((BaseSsl) jdbcConnection.getSsl()).getClientCertificate())
.sslClientPrivateKey(((BaseSsl) jdbcConnection.getSsl()).getClientPrivateKey())
.caCertificate(((BaseSsl) jdbcConnection.getSsl()).getCaCertificate())
.properties(jdbcConnection.getProperties())
.verifyCa(jdbcConnection.getSsl().getSslType() == SslType.NORMAL && ((NormalSsl) jdbcConnection.getSsl()).isVerifyCa());
}
}

2
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -590,7 +590,7 @@ public class PreviewTablePane extends BasicPane {
private void testDBTableDataConnection(TableData tableData) throws Exception { private void testDBTableDataConnection(TableData tableData) throws Exception {
if (tableData instanceof DBTableData) { if (tableData instanceof DBTableData) {
try { try {
ConnectionRepository.getInstance().testConnection(new ConnectionBean(((DBTableData) tableData).getDatabase())); ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(tableData.getName(), ((DBTableData) tableData).getDatabase()));
} catch (Exception e) { } catch (Exception e) {
throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), e); throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), e);
} }

10
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataWrapper.java

@ -6,6 +6,7 @@ import com.fr.data.impl.NameDataModel;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.gui.iprogressbar.AutoProgressBar;
@ -14,6 +15,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.workspace.server.repository.connection.ConnectionRepository;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -192,10 +194,10 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
if (tableData instanceof StoreProcedure) { if (tableData instanceof StoreProcedure) {
try { try {
connectionBar.start(); connectionBar.start();
boolean success = DataOperator.getInstance().testConnection(((StoreProcedure) getTableData()).getDatabaseConnection()); ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(((StoreProcedure) getTableData()).getDatabaseConnection()));
if (!success) { } catch (Exception e){
throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"));
} finally { } finally {
connectionBar.close(); connectionBar.close();
} }

8
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java

@ -6,6 +6,7 @@ import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.gui.iprogressbar.AutoProgressBar;
@ -14,6 +15,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.workspace.server.repository.connection.ConnectionRepository;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -178,8 +180,10 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
loadingBar.close(); loadingBar.close();
PreviewTablePane.resetPreviewTable(); PreviewTablePane.resetPreviewTable();
connectionBar.start(); connectionBar.start();
boolean status = DataOperator.getInstance().testConnection(((StoreProcedure) getTableData()).getDatabaseConnection()); try {
if (!status) { ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(((StoreProcedure) getTableData()).getDatabaseConnection()));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
connectionBar.close(); connectionBar.close();
throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"));
} }

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

@ -10,6 +10,7 @@ import com.fr.data.impl.Connection;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper;
import com.fr.design.mainframe.dnd.SerializableTransferable; import com.fr.design.mainframe.dnd.SerializableTransferable;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -103,7 +104,7 @@ public class TableViewList extends UIList {
//总共给3次连接的机会 //总共给3次连接的机会
while (!status && count > 0) { while (!status && count > 0) {
try { try {
ConnectionRepository.getInstance().testConnection(new ConnectionBean(datasource)); ConnectionRepository.getInstance().testConnection(ConnectionInfoBeanHelper.createConnectionInfoBean(databaseName, datasource));
status = true; status = true;
break; break;
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save