Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

executeQuery() error: java.lang.StringIndexOutOfBoundsException: String index out of range: -1

15 views
Skip to first unread message

Vic

unread,
Jul 21, 2003, 10:04:49 AM7/21/03
to
Hi all,

being the first time i post to this, or any group please forgive any
errors.
i try getting a resultSet from a stmt.executeQuery(query) and i get an
error.
I am using SQL7.0 and Jdb:odbc bridge.
the query is a valid sql query, tested in SQl retunrs 0 rows.

if the query returned any records at all then there is no error, but
when it returns 0 records, i get the following error:

java.lang.StringIndexOutOfBoundsException: String index out of range:
-1
at java.lang.String.substring(String.java:1444)
at sun.jdbc.odbc.JdbcOdbcResultSet.reWordAsCountQuery(JdbcOdbcResultSet.java:6562)
at sun.jdbc.odbc.JdbcOdbcResultSet.calculateRowCount(JdbcOdbcResultSet.java:6355)
at sun.jdbc.odbc.JdbcOdbcResultSet.initialize(JdbcOdbcResultSet.java:157)
at sun.jdbc.odbc.JdbcOdbcStatement.getResultSet(JdbcOdbcStatement.java:424)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:254)

which i find odd.

I tried testing the stmt.executeQuery(query) for null before i receive
it but it doesnt work. The error kicks in as soon as i pretend to
receive the ResultSet
rs = stmt.executeQuery(query)

Any ideas on how i can test the result set for null or empy before i
receive it?
Thank you

Joseph Weinstein

unread,
Jul 21, 2003, 11:41:52 AM7/21/03
to Vic

Vic wrote:

> Hi all,
>
> being the first time i post to this, or any group please forgive any
> errors.
> i try getting a resultSet from a stmt.executeQuery(query) and i get an
> error.
> I am using SQL7.0 and Jdb:odbc bridge.
> the query is a valid sql query, tested in SQl retunrs 0 rows.
>
> if the query returned any records at all then there is no error, but
> when it returns 0 records, i get the following error:
>
> java.lang.StringIndexOutOfBoundsException: String index out of range:
> -1
> at java.lang.String.substring(String.java:1444)
> at sun.jdbc.odbc.JdbcOdbcResultSet.reWordAsCountQuery(JdbcOdbcResultSet.java:6562)
> at sun.jdbc.odbc.JdbcOdbcResultSet.calculateRowCount(JdbcOdbcResultSet.java:6355)
> at sun.jdbc.odbc.JdbcOdbcResultSet.initialize(JdbcOdbcResultSet.java:157)
> at sun.jdbc.odbc.JdbcOdbcStatement.getResultSet(JdbcOdbcStatement.java:424)
> at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:254)
>
> which i find odd.

Me too. If your query is really a simple query, and not a stored procedure, then
this is a bug in the jdbc-odbc bridge. If you can get a real commercial type-4
jdbc driver you will be considerably happier.
Joe Weinstein at BEA

Vic

unread,
Jul 21, 2003, 5:26:23 PM7/21/03
to
Do you have an idea where can i find a free driver? I searched
earlier but i am not convinced on their performance.

I would rather keep this driver for the only reason that this is not
my own project. I received it from a client that lost their Software
person, whom created about 125 classes, JSPs, servlets, and Beans with
hardcoded paths and connection strings. Not only that but the project
uses about 50% ASP pages, 35% Java technology, and the rest is either
pure HTML or PHP files.
If anybody has a solution different than getting a third-party driver
please let me know.

Thanks!

vic

Joseph Weinstein <joe.rem...@bea.com.remove_this> wrote in message >

Andy Flowers

unread,
Jul 21, 2003, 5:48:15 PM7/21/03
to
Microsoft produce a free driver if memory serves.

"Vic" <vca...@maxit.biz> wrote in message
news:11814726.03072...@posting.google.com...

Joseph Weinstein

unread,
Jul 21, 2003, 6:16:22 PM7/21/03
to Andy Flowers

Andy Flowers wrote:

> Microsoft produce a free driver if memory serves.

Yes, they do, but they purposely had it hobbled to refuse connecting to
SQL7... ;-(

0 new messages