Kotlin/Java execute query to the JBDC

Hello Community,
I would like to have the ability to execute. SQL query by using Gatling Java/Kotlin DSL.
I haven’t found any plugin for it, just only for Scala.
is there any way how I can do it?

Hello,

I’m not aware of any existing work on this (there’s a third party JDBC plugin for Gatling, but that’s not something we maintain ourselves).
I’m afraid that’s something you’ll have to implement yourself (possibly contribute :slight_smile: ).

@slandelle
The main issue why I cannot implement this plugin is because java/kotlin DSL is based on wrapper.
So i don’t know to implement this.
The logic tells me, I need to use ActionBuilder.java, but I also i need to have StatsEngine.java and Action.java.
When i tried it by myself i got the exception.
If you want I can share my code or maybe you could give me advice.

upd
I haven’t found any Gatling java plugin implementation, so if you know pls share with me.

If you want I can share my code or maybe you could give me advice.

Sorry, the other people at Gatling and I really don’t have the bandwidth to help with custom plugin development. The only way we can help is with a consulting contract.

I haven’t found any Gatling java plugin implementation, so if you know pls share with me.

Gatling provides a Java DSL but it’s really just an external layer for the end user. Gatling internals are implemented in Scala. I can’t say if it’s possible to implement a plugin in Java.

I also don’t see any way how it can be done in java.
What do you think if I create a future request for it?

Do you want to make performance tests of DB or you want only some data from DB for test ?

@GeMi I need to check that data is updated in DB.
For fetching data from the DB I can use JDBCFeeder

No, that’s not the purpose of JdbcFeeder. It’s purpose is to fetch test data from the database when the Simulation starts. What you’re looking for is GitHub - Tinkoff/gatling-jdbc-plugin: Simple gatling plugin for JDBC.

@slandelle I saw this plugin, but it is Scala plugin.
I don’t think that I can run it using Gatling Kotlin/Java DSL.

No, you can’t run it in anything else than Scala. But that’s the best solution out there currently.

I have 2 propositions for your case:

  • If you have any GET API that should give you data from DB you can add it to Simulation and check if this data are updated correctly
  • You can use after() from Hooks and prepare custom Java code for DB for this case

You can try to call scala code (plugin code) from java/kotlin dsl, but it is not so obvious. Try to search through source code of plugin for request builders and use intellisense of your ide to find correct java name. I’ve tried it once and it worked.