# Getting values from a jdbcFeeder

**URL:** <https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241>\
**Category:** Gatling (Open-Source)\
**Created:** [January 21, 2013, 7:00pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241 "2013-01-21T19:00:41Z")\
**Posts on this page:** 12\
**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 21, 2013, 7:00pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241/1 "2013-01-21T19:00:41Z")

</div>

Hi - I am attempting to use a jdbcFeeder to seed data for my simulation. I have this

…**.exec(jdbcFeeder(…, “select co1, col2, col3 from table”))**  
…  
.exec(http(“request\_1”)  
.post(…)  
**.param(“user”, “${col1}”)**  
…

however, I am not able to get the value of col1 or any of the other selected columns.

Am I doing something wrong? How can I get the value of the selected columns?

I am still digesting scala, so I apologize in advance if this is obvious.

Thanks

---

<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 21, 2013, 7:23pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241/2 "2013-01-21T19:23:36Z")

</div>

Hi,

Like any other feeder, you need to use the feed(…) DSL construct to get values from your feeder into the session (which makes them available through the Gatling EL).  
Replace **exec(jdbcFeeder(…))** by **feed(JdbcFeeder(…))** and it should work.

The [Feeders documentation](https://github.com/excilys/gatling/wiki/Feeders) should help mastering Feeders 🙂

Cheers,

Pierre

---

<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 21, 2013, 7:32pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241/3 "2013-01-21T19:32:39Z")

</div>

Sorry Pierre - I had a typo in my original post. I am already sending it through a .feed().

It is still not working.

So this is what I intended to post

…  
**.exec(feed(jdbcFeeder(…, “select co1, col2, col3 from table”)))**  
…  
.exec(http(“request\_1”)  
.post(…)  
**.param(“user”, “${col1}”)**  
…

---

<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 21, 2013, 7:40pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241/4 "2013-01-21T19:40:53Z")

</div>

The problem is slightly different, but the conclusion is the same : using feed(…) is enough, you don’t need to put it inside an exec.  
Drop the exec surrounding the feed(…) and it should work.

---

<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 21, 2013, 7:53pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241/5 "2013-01-21T19:53:31Z")

</div>

hmmm, ok here is what i have…

val dataFeed = jdbcFeeder(…, “select col1, col2, col3 from table”)

val scn = scenario(“Scenario Name”)  
.feed(dataFeed)  
.repeat(loop) {

group(“Login”) {  
exec(login\_chain)  
}  
.pause(1)  
.group(“Home”) {  
exec(home\_chain)  
}  
.pause(2)  
.group(“Logout”) {  
exec(logout\_chain)  
}  
} //end repeat

Using “${col1}” or any of the other columns is not being evaluated within the groups. At minimum, I tried this…

val scn = scenario(“Scenario Name”)  
.repeat(loop) {

exec(session =\> {  
println("${col1}")  
session  
})

The println() just prints ${col1}, not the value of the column.

Can you see anything wrong. Still not working for me. I am on oracle database.

---

<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 21, 2013, 7:56pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241/6 "2013-01-21T19:56:53Z")

</div>

Of course

val scn = scenario(“Scenario Name”)  
.feed(dataFeed) **\<\< data feeder is here as well…**  
.repeat(loop) {

exec(session =\> {  
println("${col1}")  
session  
})

---

<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 21, 2013, 8:37pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241/7 "2013-01-21T20:37:47Z")

</div>

It’s perfectly normal that println() prints “${col1}” and not the value in session : EL is not specific to Gatling and is resolved only in specific places, and println() isn’t one of those.

If you wan to see what is in your session, you cant either

- print the whole session ( ex : (session =\> { println(session);session }) )

- get a specific attribute and print it (ex : (session =\> { println(session.getAttribute(“col1”); session }) )  
As an example, this works perfectly fine for me : I’m getting only the columns I want in session and they’re perfectly accessible through either EL or Session function :

val scn = scenario(“Scenario name”)  
.feed(jdbcFeeder(“jdbc:postgresql:gatling-db”,“gatling”,“gatling”,“SELECT firstname,lastname FROM Person LIMIT 20”))  
.exec(http("${firstname}").get(“[http://google.com](http://google.com)”).check(status.is(301)))  
.exec((s:Session) =\> {println(s.getAttribute(“firstname”));s})

---

<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 21, 2013, 8:39pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241/8 "2013-01-21T20:39:40Z")

</div>

My bad : I meant that the EL _is_ specific to Gatling 🙂

---

<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 21, 2013, 9:03pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241/9 "2013-01-21T21:03:30Z")

</div>

Thanks Pierre. Finally it works!

Dumping the session helped. I should have thought of that 😉

It happens the values were stored in the session in uppercase, and I was trying to retrieve them in lower case. That is why it appeared it wasn’t working.

Thanks.

Also, just related but might as well tag on to this, whenever I attempt to use the logger instead of println, i don’t see the results get printed. I modified logback.xml to log the packages under which my simulations live, but still no luck.

Does anything need to be done specially to get that to work?

eg.  
val logger = org.slf4j.LoggerFactory.getLogger(“myDebugLogger”)

in logback.xml

with my simulations under **samples** package.

---

<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 21, 2013, 9:41pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241/10 "2013-01-21T21:41:53Z")

</div>

I think the problem resides in the same of your logger.  
Basically, when you create a new logger, you use the class name as the logger name (to get the nice package-specific logger configuration)  
Replace _“myDebugLogger”_ by _MySimulation.getClass_ (if your simulation class is MySimulation) and it will work (you should of course use the corresponding logging methods, eg : logger.debug(…) )

You can also make use of a grizzled-slf4j, a library we’re using to simplify logger setup and usage in Scala, if you like.  
To do so :

- add a new import _: import grizzled.slf4j.Logging_

- Modify your class declaration so that it should look like this : _class MySimulation extends Simulation **with Logging** _

- Logger is automatically setup (eg : you don’t need the _val logger = …_ line) and you can directly call debug(…) instead of logger.debug(…)  
Cheers,

Pierre

---

<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 21, 2013, 10:15pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241/11 "2013-01-21T22:15:55Z")

</div>

Ok. I’ll try that. 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 21, 2013, 11:40pm UTC](https://community.gatling.io/t/getting-values-from-a-jdbcfeeder/241/12 "2013-01-21T23:40:18Z")

</div>

grizzled-slf4j works like a charm. Thank you
