java.sql.SQLException: Parameter index out of range

160 views
Skip to first unread message

Igor

unread,
Sep 21, 2010, 3:38:13 AM9/21/10
to dbfit
I'm getting "Parameter index out of range (1 > number of parameters,
which is 0)." when trying to run a select query with an email address.

The query looks like this:
!|Query|select username as y from users where email='f...@bar.com'|

And the error stack trace I'm getting:
java.sql.SQLException: Parameter index out of range (1 > number of
parameters, which is 0).
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at
com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:
2777)
at
com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:
2808)
at com.mysql.jdbc.PreparedStatement.setNull(PreparedStatement.java:
2844)
at com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:
3005)
at
dbfit.environment.AbstractDbEnvironment.createStatementWithBoundFixtureSymbols(AbstractDbEnvironment.java:
88)
at dbfit.fixture.Query.getDataTable(Query.java:33)
at dbfit.fixture.RowSetFixture.doRows(RowSetFixture.java:70)
at fit.Fixture.doTable(Fixture.java:153)
at fit.Fixture.interpretFollowingTables(Fixture.java:119)
at fit.Fixture.interpretTables(Fixture.java:105)
at fit.Fixture.doTables(Fixture.java:79)
at fit.FitServer.process(FitServer.java:81)
at fit.FitServer.run(FitServer.java:56)
at fit.FitServer.main(FitServer.java:41)

The other queries are working correctly. Did anybody have a similar
problem?

Igor

unread,
Sep 21, 2010, 5:10:05 AM9/21/10
to dbfit
I think the problem is in the "@" sign. Without the "@" sign the query
is working as expected. Is there any workaround for that problem?

On Sep 21, 9:38 am, Igor <igor.kostyuche...@googlemail.com> wrote:
> I'm getting "Parameter index out of range (1 > number of parameters,
> which is 0)." when trying to run a select query with an email address.
>
> The query looks like this:
> !|Query|select username as y from users where email='...@bar.com'|

Igor

unread,
Sep 21, 2010, 6:42:21 AM9/21/10
to dbfit
The problem is that dbfit interprets @-sign as a parameter. The
workaround I'm using is to set a parameter for the email-address in
the suite set up:

|Set Parameter|user_mail|so...@email.address|
|Set Parameter|user_newmail|some....@email.address|

and then to use the parameter in the tests:

!|Query|select username as y from users where email=@user_mail|
|y|
|some_user_name|

I'd love to see another approaches/workarounds.

Gojko Adzic

unread,
Sep 21, 2010, 7:18:26 AM9/21/10
to dbfit
|set option|bind symbols|false|

will prevent symbol binding

remember to turn it on back after you execute the query.

gojko

On Sep 21, 11:42 am, Igor <igor.kostyuche...@googlemail.com> wrote:
> The problem is that dbfit interprets @-sign as a parameter. The
> workaround I'm using is to set a parameter for the email-address in
> the suite set up:
>
> |Set Parameter|user_mail|s...@email.address|
> |Set Parameter|user_newmail|some.ot...@email.address|
Reply all
Reply to author
Forward
0 new messages