Idea Plugin - Using DataSource


SUBMITTED BY: Guest

DATE: June 12, 2013, 1:11 a.m.

FORMAT: Text only

SIZE: 770 Bytes

HITS: 1050

  1. import com.intellij.javaee.dataSource.DataSource;
  2. import com.intellij.javaee.dataSource.DataSourceManager;
  3. import com.intellij.javaee.dataSource.ServerInstance;
  4. import com.intellij.openapi.project.Project;
  5. import java.lang.reflect.Method;
  6. import java.sql.Connection;
  7. ...
  8. DataSourceManager dataSourceManager =
  9. DataSourceManager.getInstance(e.getProject());
  10. DataSource dataSource =
  11. dataSourceManager.getDataSourceByName("BB21_TST");
  12. Method getConnectionMethod =
  13. dataSource.getClass().getDeclaredMethod("getConnection", Project.class, ServerInstance.class);
  14. getConnectionMethod.setAccessible(true);
  15. Connection conn =
  16. (Connection) getConnectionMethod.invoke(dataSource, p, null);

comments powered by Disqus