@ -1,6 +1,7 @@
package com.fr.design.data.datapane.connect ;
package com.fr.design.data.datapane.connect ;
import com.fr.config.RemoteConfigEvent ;
import com.fr.config.RemoteConfigEvent ;
import com.fr.data.core.db.JDBCSecurityChecker ;
import com.fr.data.impl.Connection ;
import com.fr.data.impl.Connection ;
import com.fr.data.impl.ConnectionBean ;
import com.fr.data.impl.ConnectionBean ;
import com.fr.data.impl.JDBCDatabaseConnection ;
import com.fr.data.impl.JDBCDatabaseConnection ;
@ -28,6 +29,7 @@ import com.fr.transaction.WorkerFacade;
import com.fr.workspace.WorkContext ;
import com.fr.workspace.WorkContext ;
import java.awt.Window ;
import java.awt.Window ;
import java.sql.SQLException ;
import java.util.ArrayList ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.Arrays ;
import java.util.HashMap ;
import java.util.HashMap ;
@ -166,7 +168,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
/ * *
/ * *
* Update .
* Update .
* /
* /
public void update ( ConnectionConfig connectionConfig ) {
public void update ( ConnectionConfig connectionConfig ) throws Exception {
// Nameable[]居然不能强转成NameObject[],一定要这么写...
// Nameable[]居然不能强转成NameObject[],一定要这么写...
Nameable [ ] res = this . update ( ) ;
Nameable [ ] res = this . update ( ) ;
Map < String , Connection > updatedMap = new LinkedHashMap < > ( ) ;
Map < String , Connection > updatedMap = new LinkedHashMap < > ( ) ;
@ -188,10 +190,27 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
}
}
} ) ;
} ) ;
this . checkSecurity ( addedOrUpdatedConnections ) ;
this . alterConnections ( removedConnNames , addedOrUpdatedConnections ) ;
this . alterConnections ( removedConnNames , addedOrUpdatedConnections ) ;
}
}
private void checkSecurity ( List < ConnectionBean > addedOrUpdatedConnections ) throws Exception {
for ( ConnectionBean connectionBean : addedOrUpdatedConnections ) {
Connection connection = connectionBean . getConnection ( ) ;
if ( connection instanceof JDBCDatabaseConnection ) {
try {
JDBCSecurityChecker . checkURL ( ( ( JDBCDatabaseConnection ) connection ) . getURL ( ) ) ;
JDBCSecurityChecker . checkValidationQuery ( ( ( JDBCDatabaseConnection ) connection ) . getDbcpAttr ( ) . getValidationQuery ( ) ) ;
} catch ( SQLException e ) {
throw new SQLException ( Toolkit . i18nText ( "Fine-Design_Basic_Database_Connection_Invalid_Config" , connectionBean . getName ( ) ) + ", " + e . getMessage ( ) , e . getCause ( ) ) ;
}
}
}
}
private void alterConnections ( List < String > removedConnNames , List < ConnectionBean > addedOrUpdatedConnections ) {
private void alterConnections ( List < String > removedConnNames , List < ConnectionBean > addedOrUpdatedConnections ) {
try {
try {