How to access data sources which are in the /.idea/dataSources.xml in my custom plugin?
Answered
Hello,
I would like to access and modify data sources which are defined manually in the Database Tool Window. My plugin is generated from JetBrains/intellij-platform-plugin-template. That means the development language is Kotlin. The `gradle.properties` is updated with;
pluginUntilBuild = 211.*
platformType = IU
platformPlugins = com.intellij.database
Since I couldn't find the correct documentation, I tried several things by my own to access data sources like;
DbPsiFacade.getInstance(project).dataSources
// Method threw 'java.lang.ClassNotFoundException' exception.
DataSourceManager.getManagers(project)
// Method threw 'java.lang.ClassNotFoundException' exception.
Before going to the ugly usual XML updating way, I would like to get your opinions.
That would be really nice if you could redirect me to the up to date correct documentation.
Thanks in advance.
Greetings!
Please sign in to leave a comment.
ClassNotFoundException is most probably caused by not adding `<depends>` declaration in plugin.xml, please see guide in https://plugins.jetbrains.com/docs/intellij/data-grip.html
Please see https://youtrack.jetbrains.com/issue/IJSDK-104 (last comment) as starting point
Many thanks for your answer Yann! I updated the plugin.xml, and now it works.
I update the data source URL like below, it works but `dataSource.delegate as LocalDataSource` says `'getDelegate()' "is marked unstable with @ApiStatus.Internal"`. Is there any other way to update the URL?
Thanks again 🙏🏼
from javadoc
That helped, thanks a lot 🙏🏼