When developing the idea plug-in, how to execute the query sql and get the query result?
Answered

Please sign in to leave a comment.
Hi zion,
To execute a query you need to:
1. Create or get existing session (it's our wrapper for connection) by using
com.intellij.database.console.session.DatabaseSessionManager#getSessions(com.intellij.openapi.project.Project, com.intellij.database.dataSource.LocalDataSource).2. Create request
com.intellij.database.datagrid.DataRequest.RawRequestand overrideprocessRawmethod. Here you can get the connection from the second argument -com.intellij.database.dataSource.DatabaseConnectionCore#getRemoteConnection.3. Send the request for execution
session.getMessageBus().getDataProducer().processRequest(request).To get the query result you need to implement com.intellij.database.datagrid.DataConsumer and do the following before the query execution:
@Anna Rodionova Thanks!