# Using jdbcFeeder

**URL:** <https://community.gatling.io/t/using-jdbcfeeder/228>\
**Category:** Gatling (Open-Source)\
**Created:** [January 12, 2013, 7:08pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228 "2013-01-12T19:08:48Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bayo\_Erinle](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Bayo\_Erinle](https://community.gatling.io/u/Bayo_Erinle)\
**Post date:** [January 12, 2013, 7:08pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/1 "2013-01-12T19:08:48Z")

</div>

Hi -  
I am trying to use the jdbcFeeder but not having much luck.

No matter what I try, I end up with the exception below…

Simulation samples.MySimulation started…  
Exception in thread “main” java.sql.SQLException: Invalid operation for forward only resultset : isLast  
at oracle.jdbc.driver.OracleResultSetImpl.isLast(OracleResultSetImpl.java:458)  
at com.excilys.ebi.gatling.jdbc.feeder.database.JdbcFeederSource$$anonfun$apply$1$$anon$1.hasNext(JdbcFeederSource.scala:36)  
at scala.collection.Iterator$class.foreach(Iterator.scala:772)  
at com.excilys.ebi.gatling.jdbc.feeder.database.JdbcFeederSource$$anonfun$apply$1$$anon$1.foreach(JdbcFeederSource.scala:34)  
at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)

…

Here is a snippet of my simulation

**val data = jdbcFeeder(URL, user, pass, “select 1 from dual”)**  
which I later pass into a **.feed()** somewhere in my scenario.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [January 12, 2013, 7:42pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/2 "2013-01-12T19:42:45Z")

</div>

You’re probably not doing anything wrong, that’s just that ResultSet.isLast doesn’t seem to be supported by your Oracle driver.  
JDBC, such a thing of beauty…

I’ll implement the loop another way.

Could you open an issue, please?

---

<div class="post-metadata">

**Author:** ![Bayo\_Erinle](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Bayo\_Erinle](https://community.gatling.io/u/Bayo_Erinle)\
**Post date:** [January 12, 2013, 7:54pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/3 "2013-01-12T19:54:09Z")

</div>

Sure, I will. Thanks.

Another quick question (related to jdbc feeders), is it possible to do something like this?

jdbcFeeder(URL, user, pass, “select col from some\_table where col1 = ${val}”)

where val is determined from value of another feeder?

In essence, I have a csv feeder which reads values user, country is the format

user, country  
john, usa  
jane, uk  
…

Based on the country, I’ll like to seed the jdbc feeder and use the results of that feed as input params to other requests within my scenario.

I think it’s somewhat similar to [https://groups.google.com/forum/#!searchin/gatling/jdbc/gatling/RywtXllPrUU/hYMPXg0dkmcJ](https://groups.google.com/forum/#!searchin/gatling/jdbc/gatling/RywtXllPrUU/hYMPXg0dkmcJ)

Cheers

---

<div class="post-metadata">

**Author:** ![Pierre\_DAL-PRA](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@Pierre\_DAL-PRA](https://community.gatling.io/u/Pierre_DAL-PRA)\
**Post date:** [January 12, 2013, 8:29pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/4 "2013-01-12T20:29:40Z")

</div>

I have a possible fix for your problems with the JDBC feeder and built a snapshot, can you try it and tell me if it works ?  
Here is the link : [https://docs.google.com/file/d/0B746qfUom-IrREpHaDltSUMzYUE/edit](https://docs.google.com/file/d/0B746qfUom-IrREpHaDltSUMzYUE/edit)

---

<div class="post-metadata">

**Author:** ![Bayo\_Erinle](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Bayo\_Erinle](https://community.gatling.io/u/Bayo_Erinle)\
**Post date:** [January 12, 2013, 8:43pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/5 "2013-01-12T20:43:25Z")

</div>

Nice. That works!

Is there any way I can grab this when updates like this if I am not using the bundle?? (i.e. working with from a generated maven-archetype within the IDE)

Also, can you advice me on my other question above?

---

<div class="post-metadata">

**Author:** ![Pierre\_DAL-PRA](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@Pierre\_DAL-PRA](https://community.gatling.io/u/Pierre_DAL-PRA)\
**Post date:** [January 12, 2013, 9:13pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/6 "2013-01-12T21:13:00Z")

</div>

Nice to that it works, I’ll commit it shortly.

I think of two possibilities to grab snapshots without using the bundle.

1/ You can use Gatling’s forge public Maven repositories.  
in the repositories section of your pom.xml, add :  
  
forge  
Gatling’s Forge  
dav:[http://repository-gatling.forge.cloudbees.com/snapshot/](http://repository-gatling.forge.cloudbees.com/snapshot/)  
  
true

and change the Gatling’s version you’re depending on with \<gatling.version\>1.X.X\</gatling.version\> in the properties section.  
In this case, if you want to depend from latest snapshot from the 1.4.X branch (recommanded, as it’s a maintenance branch), you would to have to replace the \<gatling.version\> line by : \<gatling.version\>1.4.2-SNAPSHOT\</gatling.version\>

2/ You can clone Gatling’s git repos, build the snapshots whenever you need a feature not yet released, and change the Gatling’s version you’re depending on to match latest snapshot from git.

About your other question, it’s not currently possible to use “dynamic queries”.  
I may be wrong, but feeders’ data is fetched before simulation starts and therefore can hardly depend on what’s going on in your simulation 🙂

---

<div class="post-metadata">

**Author:** ![Bayo\_Erinle](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Bayo\_Erinle](https://community.gatling.io/u/Bayo_Erinle)\
**Post date:** [January 12, 2013, 9:25pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/7 "2013-01-12T21:25:36Z")

</div>

Ok. Thanks Pierre. I’ll wait for the commit and try the 2 approaches you suggested to get updates without waiting on bundles.

As for the feeders, that seems quite limiting :(. Those values would be available on the http session on the server, but I can’t get to those either, so this was the next best thing to try.

How can we vote up or make feature requests. I can imagine a lot of people will find this useful.

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Pierre\_DAL-PRA](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@Pierre\_DAL-PRA](https://community.gatling.io/u/Pierre_DAL-PRA)\
**Post date:** [January 12, 2013, 9:31pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/8 "2013-01-12T21:31:39Z")

</div>

You can make feature request by creating a new issue on Github : [https://github.com/excilys/gatling/issues/new](https://github.com/excilys/gatling/issues/new)

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [January 12, 2013, 10:27pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/9 "2013-01-12T22:27:39Z")

</div>

@groovybayo Feeders are shared data sources ([https://github.com/excilys/gatling/wiki/Feeders#wiki-what](https://github.com/excilys/gatling/wiki/Feeders#wiki-what)) while what you’re trying to achieve depends on user data.

I have the feeling you’re not trying to get the data from the right place. Gatling is supposed to emulate real users, and real users dont get the data directly from the database, but from the pages. Are you sure that you shouldn’t be using checks with saveAs?

Stéphane

---

<div class="post-metadata">

**Author:** ![Bayo\_Erinle](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Bayo\_Erinle](https://community.gatling.io/u/Bayo_Erinle)\
**Post date:** [January 12, 2013, 11:34pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/10 "2013-01-12T23:34:19Z")

</div>

Hmmm, the data is stored in the http session on the server. A client can get to those info via that, but I can’t also get hold of that.

I’ll explore the path of using .saveAs like you have suggested.

Thanks

---

<div class="post-metadata">

**Author:** ![Bayo\_Erinle](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Bayo\_Erinle](https://community.gatling.io/u/Bayo_Erinle)\
**Post date:** [January 14, 2013, 2:18pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/11 "2013-01-14T14:18:53Z")

</div>

Stephane - Thanks! I explored the saveAs path and it does get me there for about 90% of the things I need, which I am quite happy about.

The other 10% is not achievable at this point except the application is rewritten in some fashion. These values I need to get to are embedded in the http session on the server and not returned as part of any response data (html or json).

I appreciate all your help.

Thanks.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [January 14, 2013, 2:25pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/12 "2013-01-14T14:25:47Z")

</div>

Could you explain your use case?  
How do normal users browse your webapp without relying on this data that’s only on the server side?

---

<div class="post-metadata">

**Author:** ![Bayo\_Erinle](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Bayo\_Erinle](https://community.gatling.io/u/Bayo_Erinle)\
**Post date:** [January 14, 2013, 7:56pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/13 "2013-01-14T19:56:21Z")

</div>

Our application performs search which could vary based on which user is logged in. When a user logs in, we either execute the last search they executed at the time they last logged in, or execute a default search if they don’t have any (say the just logged into the system for the first time).

The logic that determines what search to run happens behind the scene, i.e. (should i run a default search or execute the last search for a given user), and only returns the end results of the search to the user. Since that part is done on the server, the user actually never gets a response of which search was run. They only see the end results of the search.

When recording our scenarios, we need to know which search to run based on the current logged in user.

A request like this is formed, based on which search needs to be executed…

exec(http(“request\_1”)  
.**post(…)**  
.headers(…)  
**.param(“search\_id”, “123”)**  
.param(…)  
…)

Since we never returned **search\_id** to a user in any of their response data, we don’t know which id to pass in for this request. Also, this are dynamic in nature for a user, so they same search id is not always guaranteed to be tied to a user.

I hope that makes some sense.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [January 14, 2013, 8:21pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/14 "2013-01-14T20:21:22Z")

</div>

Can't you build 2 similar, yet different scenarios? Can't you make a  
JdbcFeeder for users with default search and one for regular ones?  
If you can do that, you can run both populations in the same Simulation.

---

<div class="post-metadata">

**Author:** ![Bayo\_Erinle](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Bayo\_Erinle](https://community.gatling.io/u/Bayo_Erinle)\
**Post date:** [January 14, 2013, 8:48pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/15 "2013-01-14T20:48:34Z")

</div>

Stephane - I wish it was that simple. As I mentioned before, the logic to determine what search to run is completely housed and transparent to the logged in user and that these values are dynamic in nature.

A jdbcFeeder will create the values up front from my understanding, which doesn’t leave any room for dynamic nature of this. More pressing is the fact the logic that encapsulates which search to run. I don’t see a way (or can’t think of one right now) to encapsulate that in DB, without doing some much unwarranted fire fighting.

I’ll keep digging…

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [January 14, 2013, 9:44pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/16 "2013-01-14T21:44:26Z")

</div>

Your problem is not really related to Gatling, you would face it whatever  
the tool.  
I'm afraid you don't have a choice and have to build a feature dedicated to  
exposing some HTTP session values (would be best over HTTP). Of course,  
this feature doesn't have to be enabled on your live system.

---

<div class="post-metadata">

**Author:** ![Bayo\_Erinle](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@Bayo\_Erinle](https://community.gatling.io/u/Bayo_Erinle)\
**Post date:** [January 14, 2013, 10:30pm UTC](https://community.gatling.io/t/using-jdbcfeeder/228/17 "2013-01-14T22:30:43Z")

</div>

Correct. This is not Gatling specific but I was hoping it had some magic bullet there to solve this 😉

I appreciate all your help with this

Thanks
