import com.intellij.javaee.dataSource.DataSource;
import com.intellij.javaee.dataSource.DataSourceManager;
import com.intellij.javaee.dataSource.ServerInstance;
import com.intellij.openapi.project.Project;
import java.lang.reflect.Method;
import java.sql.Connection;
...
DataSourceManager dataSourceManager =
DataSourceManager.getInstance(e.getProject());
DataSource dataSource =
dataSourceManager.getDataSourceByName("BB21_TST");
Method getConnectionMethod =
dataSource.getClass().getDeclaredMethod("getConnection", Project.class, ServerInstance.class);
getConnectionMethod.setAccessible(true);
Connection conn =
(Connection) getConnectionMethod.invoke(dataSource, p, null);