Thread: unterminated quoted string

unterminated quoted string

From
"Alexey Yudichev"
Date:
Having the code

      String SQL = "SELECT COUNT(*) FROM Destination WHERE address=?";
      st = conn.prepareStatement(SQL);
      st.setString(1, address);
      rs = st.executeQuery();

and if address is an empty string, sometimes (very rarely) i get

java.sql.SQLException: ERROR:  Unterminated quoted string

        at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
        at org.postgresql.Connection.ExecSQL(Connection.java:398)
        at org.postgresql.jdbc2.Statement.execute(Statement.java:130)
        at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
        at org.postgresql.jdbc2.PreparedStatement.executeQuery(PreparedStatement.java:99)

I use PostgreSQL 7.1 and PostgreSQL 7.2 driver with "compatible=7.1" option.


Re: unterminated quoted string

From
Barry Lind
Date:
Alexey,

If you had statement logging turned on on the server you would see the
exact sql statement that the server was complaining about.  That would
be very useful to know.

thanks,
--Barry


Alexey Yudichev wrote:
> Having the code
>
>       String SQL = "SELECT COUNT(*) FROM Destination WHERE address=?";
>       st = conn.prepareStatement(SQL);
>       st.setString(1, address);
>       rs = st.executeQuery();
>
> and if address is an empty string, sometimes (very rarely) i get
>
> java.sql.SQLException: ERROR:  Unterminated quoted string
>
>         at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
>         at org.postgresql.Connection.ExecSQL(Connection.java:398)
>         at org.postgresql.jdbc2.Statement.execute(Statement.java:130)
>         at org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
>         at org.postgresql.jdbc2.PreparedStatement.executeQuery(PreparedStatement.java:99)
>
> I use PostgreSQL 7.1 and PostgreSQL 7.2 driver with "compatible=7.1" option.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>


Re: unterminated quoted string

From
"Alexey Yudichev"
Date:
The server is on high load and produces approx 1GB of statement logs every 3 days. And as I said, it happens very
veryrarely (last time I saw it was 2 months ago and then two days ago again). Is there any way to turn on only log of
statementswith errors? Or maybe is there any way to turn on debug logging on the side of the driver?  

> -----Original Message-----
> From: Barry Lind [mailto:blind@xythos.com]
> Sent: Monday, April 14, 2003 19:04
> To: Alexey Yudichev
> Cc: pgsql-jdbc@postgresql.org
> Subject: Re: [JDBC] unterminated quoted string
>
>
> Alexey,
>
> If you had statement logging turned on on the server you
> would see the
> exact sql statement that the server was complaining about.
> That would
> be very useful to know.
>
> thanks,
> --Barry
>
>
> Alexey Yudichev wrote:
> > Having the code
> >
> >       String SQL = "SELECT COUNT(*) FROM Destination WHERE
> address=?";
> >       st = conn.prepareStatement(SQL);
> >       st.setString(1, address);
> >       rs = st.executeQuery();
> >
> > and if address is an empty string, sometimes (very rarely) i get
> >
> > java.sql.SQLException: ERROR:  Unterminated quoted string
> >
> >         at
> org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94)
> >         at org.postgresql.Connection.ExecSQL(Connection.java:398)
> >         at
> org.postgresql.jdbc2.Statement.execute(Statement.java:130)
> >         at
> org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)
> >         at
> org.postgresql.jdbc2.PreparedStatement.executeQuery(PreparedSt
> atement.java:99)
> >
> > I use PostgreSQL 7.1 and PostgreSQL 7.2 driver with
> "compatible=7.1" option.
> >
> >
> > ---------------------------(end of
> broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to
> majordomo@postgresql.org
> >
>
>
>
>


Re: unterminated quoted string

From
Holger Klawitter
Date:
> > > and if address is an empty string, sometimes (very rarely) i get
> > >
> > > java.sql.SQLException: ERROR:  Unterminated quoted string

I once in a while got a similar error when somehow a '\0' managed to sneek
inside a string. As a result, the whole Tomcat<->Postgresql communication
stopped (in most cases). The problem probably comes from the different
treatment of zeroes in Strings in Java and C/C++.

I solved the problem by filtering out such zeroes before passing them as
parameters into prepared statements.

Mit freundlichem Gruß / With kind regards
    Holger Klawitter
--
lists@klawitter.de