Subject | How to mask ' ? |
---|---|
Author | Carsten Schäfer |
Post date | 2006-03-20T08:45:19Z |
I've a problem with finding strings with '.
I'v tested Firebird 1.5 and FB2.0, Jaybird 1.5 and Jaybird 2.0.1 on Windows.
All with the same error.
I have a varchar column F_ANR_KUNDE with content "111111'2222" and want
to search for that string.
I'm using a PreparedStatement:
SELECT t_apos.ID_APOS,
t_apos.f_liefer_nr,t_apos.f_status,t_apos.f_id_auftrag,t_auftrag.f_id_kunde
FROM t_apos JOIN t_auftrag ON f_id_auftrag = id_auftrag WHERE
(t_apos.f_anr_kunde LIKE ? ESCAPE '\') AND t_apos.f_id_auftrag + 0 != 0
I tried to mask the ' with '' -> Nothing is found.
I tried to mask the ' with \' -> Something is found, but i get an
exception in fetch ?
GDS Exception. 335544702. Invalid ESCAPE sequence
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544702. Invalid
ESCAPE sequence
at
org.firebirdsql.jdbc.FBStatementFetcher.fetch(FBStatementFetcher.java:206)
at
org.firebirdsql.jdbc.FBStatementFetcher.next(FBStatementFetcher.java:119)
at org.firebirdsql.jdbc.FBResultSet.next(FBResultSet.java:250)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.firebirdsql.pool.ResultSetHandler.invoke(ResultSetHandler.java:70)
at $Proxy2.next(Unknown Source)
at
com.TTC_Informatik.PAULA.Tools.DB.DBAPosSuche.getPassendePositionen(DBAPosSuche.java:252)
at
com.TTC_Informatik.PAULA.server.App_Server.erzeugeSuchergebnis(App_Server.java:4824)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
at org.firebirdsql.gds.GDSException: Invalid ESCAPE sequence
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.readStatusVector(AbstractJavaGDSImpl.java:2104)
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.receiveResponse(AbstractJavaGDSImpl.java:2054)
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlFetch(AbstractJavaGDSImpl.java:1322)
at org.firebirdsql.gds.impl.GDSHelper.fetch(GDSHelper.java:260)
at
org.firebirdsql.jdbc.FBStatementFetcher.fetch(FBStatementFetcher.java:201)
at
org.firebirdsql.jdbc.FBStatementFetcher.next(FBStatementFetcher.java:119)
at org.firebirdsql.jdbc.FBResultSet.next(FBResultSet.java:250)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.firebirdsql.pool.ResultSetHandler.invoke(ResultSetHandler.java:70)
at $Proxy2.next(Unknown Source)
at
com.TTC_Informatik.PAULA.Tools.DB.DBAPosSuche.getPassendePositionen(DBAPosSuche.java:252)
I use a FBWrappingDataSource(Type 4 driver) with
dataSource.setEncoding("WIN1252");
What is the correct way to mask the ' ?
(In IbExpert the query ist working when i replace the ? with '111111''2222')
mfg
Carsten
I'v tested Firebird 1.5 and FB2.0, Jaybird 1.5 and Jaybird 2.0.1 on Windows.
All with the same error.
I have a varchar column F_ANR_KUNDE with content "111111'2222" and want
to search for that string.
I'm using a PreparedStatement:
SELECT t_apos.ID_APOS,
t_apos.f_liefer_nr,t_apos.f_status,t_apos.f_id_auftrag,t_auftrag.f_id_kunde
FROM t_apos JOIN t_auftrag ON f_id_auftrag = id_auftrag WHERE
(t_apos.f_anr_kunde LIKE ? ESCAPE '\') AND t_apos.f_id_auftrag + 0 != 0
I tried to mask the ' with '' -> Nothing is found.
I tried to mask the ' with \' -> Something is found, but i get an
exception in fetch ?
GDS Exception. 335544702. Invalid ESCAPE sequence
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544702. Invalid
ESCAPE sequence
at
org.firebirdsql.jdbc.FBStatementFetcher.fetch(FBStatementFetcher.java:206)
at
org.firebirdsql.jdbc.FBStatementFetcher.next(FBStatementFetcher.java:119)
at org.firebirdsql.jdbc.FBResultSet.next(FBResultSet.java:250)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.firebirdsql.pool.ResultSetHandler.invoke(ResultSetHandler.java:70)
at $Proxy2.next(Unknown Source)
at
com.TTC_Informatik.PAULA.Tools.DB.DBAPosSuche.getPassendePositionen(DBAPosSuche.java:252)
at
com.TTC_Informatik.PAULA.server.App_Server.erzeugeSuchergebnis(App_Server.java:4824)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
at org.firebirdsql.gds.GDSException: Invalid ESCAPE sequence
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.readStatusVector(AbstractJavaGDSImpl.java:2104)
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.receiveResponse(AbstractJavaGDSImpl.java:2054)
at
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDsqlFetch(AbstractJavaGDSImpl.java:1322)
at org.firebirdsql.gds.impl.GDSHelper.fetch(GDSHelper.java:260)
at
org.firebirdsql.jdbc.FBStatementFetcher.fetch(FBStatementFetcher.java:201)
at
org.firebirdsql.jdbc.FBStatementFetcher.next(FBStatementFetcher.java:119)
at org.firebirdsql.jdbc.FBResultSet.next(FBResultSet.java:250)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.firebirdsql.pool.ResultSetHandler.invoke(ResultSetHandler.java:70)
at $Proxy2.next(Unknown Source)
at
com.TTC_Informatik.PAULA.Tools.DB.DBAPosSuche.getPassendePositionen(DBAPosSuche.java:252)
I use a FBWrappingDataSource(Type 4 driver) with
dataSource.setEncoding("WIN1252");
What is the correct way to mask the ' ?
(In IbExpert the query ist working when i replace the ? with '111111''2222')
mfg
Carsten