[prev in list] [next in list] [prev in thread] [next in thread]
List: solid
Subject: Re: Problem with JDBC driver for Solid 2.3 - PreparedStatement
From: Jeff Lewis <jlewis () burly ! com>
Date: 1999-08-11 19:27:52
[Download RAW message or body]
Hi Donald --
It's not a problem with Solid's jdbc driver, it just happens to be how
you're trying to use the prepared statement. How about trying the
following instead:
// Prepare the statement.
String psstr = "select id, title from titles where title like ?";
PreparedStatement pstmt = con.prepareStatement(psstr);
...
// for some passed in String val = "test";
pstmt.setString(1, "%"+val+"%");
ResultSet res = pstmt.executeQuery();
while(res.next())
{
... // do something with the results
}
...
-- J
On Wed, 11 Aug 1999, Donald Ball wrote:
> Hi, I'm having some trouble with Solid's JDBC driver for the Web Engine
> 2.3. I'm trying to use preparedStatements that look like this:
>
> select id,title from titles where title like '%?%'
>
> when I prepare the statement, it parses okay, but when I call
>
> pst.setString(1,"test");
>
> I get this exception:
>
> java.sql.SQLException: [SOLID JDBC 2.3] Invalid parameter number
> at solid.jdbc.S_11ii11.S_11I111II1IIIi(S_11ii11.java)
> at solid.jdbc.SolidConnection.S_iI1ii1I1iI1I(SolidConnection.java)
> at
> solid.jdbc.SolidPreparedStatement.S_1I1ii1I1iI1I(SolidPreparedStatement.java)
> at
> solid.jdbc.SolidPreparedStatement.setString(SolidPreparedStatement.java)
>
> This query works fine:
>
> select id,title from titles where title like ?
>
> but doesn't do the query I really want.
>
> This query:
>
> select id,title from titles where title like %?%
>
> throws this exception:
>
> java.sql.SQLException: [SOLID JDBC 2.3] SOLID Table Error 13037: Illegal
> DOUBLE PREC constant %
> at solid.jdbc.S_11ii11.S_11I111II1IIIi(S_11ii11.java)
> at solid.jdbc.SolidConnection.AddError(SolidConnection.java)
> at solid.jdbc.SolidStatement.S_i2ii112III1(SolidStatement.java)
> at solid.jdbc.SolidStatement.S_1I1ii1I1iI11(SolidStatement.java)
> at
> solid.jdbc.SolidPreparedStatement.<init>(SolidPreparedStatement.java)
> at solid.jdbc.SolidConnection.prepareStatement(SolidConnection.java)
>
> Any suggestions on how I can handle this with PreparedStatements? I like
> to use them since they automatically escape single quotes in string
> parameters, but apparantly that side effect is causing some serious
> trouble here.
>
> - donald
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic