# Kotlin/Java execute query to the JBDC

**URL:** <https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097>\
**Category:** Gatling (Open-Source)\
**Created:** [August 25, 2022, 8:26am UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097 "2022-08-25T08:26:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Valeriy609](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@Valeriy609](https://community.gatling.io/u/Valeriy609)\
**Post date:** [August 25, 2022, 8:26am UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097/1 "2022-08-25T08:26:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [August 25, 2022, 8:49am UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097/2 "2022-08-25T08:49:05Z")

</div>

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 🙂 ).

---

<div class="post-metadata">

**Author:** ![Valeriy609](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@Valeriy609](https://community.gatling.io/u/Valeriy609)\
**Post date:** [August 29, 2022, 7:28am UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097/3 "2022-08-29T07:28:47Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [August 29, 2022, 7:59am UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097/4 "2022-08-29T07:59:03Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![Valeriy609](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@Valeriy609](https://community.gatling.io/u/Valeriy609)\
**Post date:** [August 29, 2022, 8:28am UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097/5 "2022-08-29T08:28:25Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![GeMi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/gemi/32/939_2.png) [@GeMi](https://community.gatling.io/u/GeMi)\
**Post date:** [August 29, 2022, 5:56pm UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097/6 "2022-08-29T17:56:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Valeriy609](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@Valeriy609](https://community.gatling.io/u/Valeriy609)\
**Post date:** [August 30, 2022, 7:39am UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097/7 "2022-08-30T07:39:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [August 30, 2022, 9:44am UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097/8 "2022-08-30T09:44:03Z")

</div>

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](https://github.com/Tinkoff/gatling-jdbc-plugin).

---

<div class="post-metadata">

**Author:** ![Valeriy609](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@Valeriy609](https://community.gatling.io/u/Valeriy609)\
**Post date:** [August 31, 2022, 8:48am UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097/9 "2022-08-31T08:48:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [August 31, 2022, 9:13am UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097/10 "2022-08-31T09:13:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GeMi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/gemi/32/939_2.png) [@GeMi](https://community.gatling.io/u/GeMi)\
**Post date:** [August 31, 2022, 9:37am UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097/11 "2022-08-31T09:37:38Z")

</div>

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](https://gatling.io/docs/gatling/reference/current/core/simulation/#hooks) and prepare custom Java code for DB for this case

---

<div class="post-metadata">

**Author:** ![oddfrost](https://avatars.discourse-cdn.com/v4/letter/o/5fc32e/32.png) [@oddfrost](https://community.gatling.io/u/oddfrost)\
**Post date:** [August 31, 2022, 5:28pm UTC](https://community.gatling.io/t/kotlin-java-execute-query-to-the-jbdc/7097/12 "2022-08-31T17:28:23Z")

</div>

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.
