Refresh DataSource automatically



I create a plugin that should automatically manage one data source configured by changing configuration.

I was able to create that data source with the following code:

LocalDataSource dataSource = LocalDataSource.fromDriver(driver, connectionUrl, false);

To update the configuration of the data source I remove it and add a newly configured instance.

Sadly the auto completion for table names and fields is only availabel after opening the Database panel, selecting the options of the data source and clicking refersh.

I didn't find a way to trigger this refresh on the data source, or on the localDataSourceManager.

Is there a way to automatically trigger this update after adding the data source? Or is there even a better way to provide an automatically configured data source, that might update from time to time?

Is SchemaControl.AUTOMATIC the correct setting if I would like IntelliJ to index all databaseses of that server? Or is it even related to that. It doesn't look like.

Thanks in advance!


We don't have database functionality as it is under hard development.
I recommend you to use com.intellij.database.autoconfig.DataSourceRegistry to create data sources as it is more stable.
To sync DS use com.intellij.database.util.DataSourceUtil#performAutoSyncTask(com.intellij.openapi.project.Project, com.intellij.database.dataSource.LocalDataSource)
But I don't recommend to call it without explicit user action, as it is time consuming, may show modal dialogs etc





Thank you very much Alexander Kass I was searching for something like the DataSourceUtil#performAutoSyncTask() for hours!

I would like to note that you have to add 


 otherwise the performAutoSyncTask seems to have no effect.


Yes, that is auto sync :) Thought we have it by default




Hello, I think what you did is interesting.
I am new to Datagrip,
How to implement your improvement in my idea?


Please sign in to leave a comment.