String constant too long (SQL0102N) 
Author Message
 String constant too long (SQL0102N)

Hello,

I'm running java 1.2.2 on aix 4.3.  Using DB2 05.01.0001 with OpenLink
opljdbc2 driver 3.20.10.22.  Using Jakarta-Tomcat 3.2.1 servlet engine,
default settings.

I have a column defined in database "table" as MESSAGE LONG VARCHAR.

"message" is a java String which is 1043 characters long.  Begins with
"blah, blah".

I execute:

sql = "insert into table (MESSAGE) values ('" + message + "')";
Statement s = dbCon0.createStatement();
s.setMaxFieldSize(5000);
ResultSet r = s.executeQuery(sql);

Ths results in SQL0102N "The string constant beginning with "blah, blah"
is too long.  SQLSTATE=54002.

Any suggestions on what can I do about this?  Thanks.

-ron

--
Ron Parker
Software Creations             http://www.***.com/
TradeWinds Publishing         http://www.***.com/
TradePoint Los Angeles         http://www.***.com/
SiteDirector Security Server   http://www.***.com/
Civil War Online Library       http://www.***.com/



Sun, 24 Aug 2003 18:33:50 GMT
 String constant too long (SQL0102N)

At least for Oracle I know 4K limit for method setString().
If your character=4 byte then looks like there is 4K limit
for DB2 also.

There is way to use streams here:

pst = con.prepareSatement(.........?.......);
pst.setCharacterStream(1, new java.io.StringWriter(message) );

(you may hit 32K limit also....)

AlexV


Quote:
> Hello,

> I'm running java 1.2.2 on aix 4.3.  Using DB2 05.01.0001 with OpenLink
> opljdbc2 driver 3.20.10.22.  Using Jakarta-Tomcat 3.2.1 servlet engine,
> default settings.

> I have a column defined in database "table" as MESSAGE LONG VARCHAR.

> "message" is a java String which is 1043 characters long.  Begins with
> "blah, blah".

> I execute:

> sql = "insert into table (MESSAGE) values ('" + message + "')";
> Statement s = dbCon0.createStatement();
> s.setMaxFieldSize(5000);
> ResultSet r = s.executeQuery(sql);

> Ths results in SQL0102N "The string constant beginning with "blah, blah"
> is too long.  SQLSTATE=54002.

> Any suggestions on what can I do about this?  Thanks.

> -ron

> --
> Ron Parker
> Software Creations            http://www.scbbs.com
> TradeWinds Publishing         http://www.intl-trade.com
> TradePoint Los Angeles        http://www.tradepointla.org
> SiteDirector Security Server  http://livepublish.scbbs.com
> Civil War Online Library      http://civilwar.scbbs.com



Sun, 24 Aug 2003 20:50:23 GMT
 String constant too long (SQL0102N)
Ron,

this sounds like a bug. Have you tried to print out the statement in your
Java app and run it as a script or from the command line processor.
Can you please post the table DDL?
What's the result when you use the DB2 JDBC driver?

Regards, Dirk


Quote:
> Hello,

> I'm running java 1.2.2 on aix 4.3.  Using DB2 05.01.0001 with OpenLink
> opljdbc2 driver 3.20.10.22.  Using Jakarta-Tomcat 3.2.1 servlet engine,
> default settings.

> I have a column defined in database "table" as MESSAGE LONG VARCHAR.

> "message" is a java String which is 1043 characters long.  Begins with
> "blah, blah".

> I execute:

> sql = "insert into table (MESSAGE) values ('" + message + "')";
> Statement s = dbCon0.createStatement();
> s.setMaxFieldSize(5000);
> ResultSet r = s.executeQuery(sql);

> Ths results in SQL0102N "The string constant beginning with "blah, blah"
> is too long.  SQLSTATE=54002.

> Any suggestions on what can I do about this?  Thanks.

> -ron

> --
> Ron Parker
> Software Creations            http://www.scbbs.com
> TradeWinds Publishing         http://www.intl-trade.com
> TradePoint Los Angeles        http://www.tradepointla.org
> SiteDirector Security Server  http://livepublish.scbbs.com
> Civil War Online Library      http://civilwar.scbbs.com



Mon, 25 Aug 2003 01:44:46 GMT
 String constant too long (SQL0102N)
Thanks.  This is what I tried:

NEW CODE:
   String message = "This is a test.";
   int len = message.length();
      String sql = "insert into uidlog (key, message) values ('0', ?)";
   PreparedStatement pst = con.prepareStatement(sql);
   pst.setCharacterStream(2, new java.io.StringReader (message), len);
      ResultSet rs = pst.executeQuery();

NEW ERROR MESSAGE:
[OPLJDBC2] Method not implemented
java.sql.SQLException: [OPLJDBC2] Method not implemented
        at openlink.jdbc2.OPLUtility.makeException(OPLUtility.java:56)
        at
openlink.jdbc2.OPLPreparedStatement.setCharacterStream(OPLPreparedSta
tement.java:691)
        at testConnect2.main(testConnect2.java:29)

Am I doing this right?

Quote:

> At least for Oracle I know 4K limit for method setString().
> If your character=4 byte then looks like there is 4K limit
> for DB2 also.

> There is way to use streams here:

> pst = con.prepareSatement(.........?.......);
> pst.setCharacterStream(1, new java.io.StringWriter(message) );

> (you may hit 32K limit also....)

> AlexV



> > Hello,

> > I'm running java 1.2.2 on aix 4.3.  Using DB2 05.01.0001 with OpenLink
> > opljdbc2 driver 3.20.10.22.  Using Jakarta-Tomcat 3.2.1 servlet engine,
> > default settings.

> > I have a column defined in database "table" as MESSAGE LONG VARCHAR.

> > "message" is a java String which is 1043 characters long.  Begins with
> > "blah, blah".

> > I execute:

> > sql = "insert into table (MESSAGE) values ('" + message + "')";
> > Statement s = dbCon0.createStatement();
> > s.setMaxFieldSize(5000);
> > ResultSet r = s.executeQuery(sql);

> > Ths results in SQL0102N "The string constant beginning with "blah, blah"
> > is too long.  SQLSTATE=54002.

> > Any suggestions on what can I do about this?  Thanks.

> > -ron

> > --
> > Ron Parker
> > Software Creations            http://www.scbbs.com
> > TradeWinds Publishing         http://www.intl-trade.com
> > TradePoint Los Angeles        http://www.tradepointla.org
> > SiteDirector Security Server  http://livepublish.scbbs.com
> > Civil War Online Library      http://civilwar.scbbs.com

--
Ron Parker
Software Creations            http://www.scbbs.com
TradeWinds Publishing         http://www.intl-trade.com
TradePoint Los Angeles        http://www.tradepointla.org
SiteDirector Security Server  http://livepublish.scbbs.com
Civil War Online Library      http://civilwar.scbbs.com


Mon, 25 Aug 2003 11:19:41 GMT
 String constant too long (SQL0102N)
OK, you next bet can be on

pst.setAsciiStrean(2, new java.io.StringBufferInputStream(message), len)

StringBufferInputStream will cause "deprecated" message, but alternative
is to get new driver of proper jdbc2.0 level...

also, for insert they suggest using executeUpdate(), not executeQuery()

AlexV


Quote:
> Thanks.  This is what I tried:

> NEW CODE:
>    String message = "This is a test.";
>    int len = message.length();
>       String sql = "insert into uidlog (key, message) values ('0', ?)";
>    PreparedStatement pst = con.prepareStatement(sql);
>    pst.setCharacterStream(2, new java.io.StringReader (message), len);
>       ResultSet rs = pst.executeQuery();

> NEW ERROR MESSAGE:
> [OPLJDBC2] Method not implemented
> java.sql.SQLException: [OPLJDBC2] Method not implemented
>         at openlink.jdbc2.OPLUtility.makeException(OPLUtility.java:56)
>         at
> openlink.jdbc2.OPLPreparedStatement.setCharacterStream(OPLPreparedSta
> tement.java:691)
>         at testConnect2.main(testConnect2.java:29)

> Am I doing this right?


> > At least for Oracle I know 4K limit for method setString().
> > If your character=4 byte then looks like there is 4K limit
> > for DB2 also.

> > There is way to use streams here:

> > pst = con.prepareSatement(.........?.......);
> > pst.setCharacterStream(1, new java.io.StringWriter(message) );

> > (you may hit 32K limit also....)

> > AlexV



> > > Hello,

> > > I'm running java 1.2.2 on aix 4.3.  Using DB2 05.01.0001 with OpenLink
> > > opljdbc2 driver 3.20.10.22.  Using Jakarta-Tomcat 3.2.1 servlet
engine,
> > > default settings.

> > > I have a column defined in database "table" as MESSAGE LONG VARCHAR.

> > > "message" is a java String which is 1043 characters long.  Begins with
> > > "blah, blah".

> > > I execute:

> > > sql = "insert into table (MESSAGE) values ('" + message + "')";
> > > Statement s = dbCon0.createStatement();
> > > s.setMaxFieldSize(5000);
> > > ResultSet r = s.executeQuery(sql);

> > > Ths results in SQL0102N "The string constant beginning with "blah,
blah"
> > > is too long.  SQLSTATE=54002.

> > > Any suggestions on what can I do about this?  Thanks.

> > > -ron

> > > --
> > > Ron Parker
> > > Software Creations            http://www.scbbs.com
> > > TradeWinds Publishing         http://www.intl-trade.com
> > > TradePoint Los Angeles        http://www.tradepointla.org
> > > SiteDirector Security Server  http://livepublish.scbbs.com
> > > Civil War Online Library      http://civilwar.scbbs.com

> --
> Ron Parker
> Software Creations            http://www.scbbs.com
> TradeWinds Publishing         http://www.intl-trade.com
> TradePoint Los Angeles        http://www.tradepointla.org
> SiteDirector Security Server  http://livepublish.scbbs.com
> Civil War Online Library      http://civilwar.scbbs.com



Mon, 25 Aug 2003 11:37:38 GMT
 String constant too long (SQL0102N)
Thanks!  I finally succeeded with:

   String sql = "insert into uidlog (logkey, message) values ('0', ?)";
   PreparedStatement pst = con.prepareStatement(sql);
   pst.setString(1, message);
   ResultSet rs = pst.executeQuery();

Quote:

> OK, you next bet can be on

> pst.setAsciiStrean(2, new java.io.StringBufferInputStream(message), len)

> StringBufferInputStream will cause "deprecated" message, but alternative
> is to get new driver of proper jdbc2.0 level...

> also, for insert they suggest using executeUpdate(), not executeQuery()

> AlexV



> > Thanks.  This is what I tried:

> > NEW CODE:
> >    String message = "This is a test.";
> >    int len = message.length();
> >       String sql = "insert into uidlog (key, message) values ('0', ?)";
> >    PreparedStatement pst = con.prepareStatement(sql);
> >    pst.setCharacterStream(2, new java.io.StringReader (message), len);
> >       ResultSet rs = pst.executeQuery();

> > NEW ERROR MESSAGE:
> > [OPLJDBC2] Method not implemented
> > java.sql.SQLException: [OPLJDBC2] Method not implemented
> >         at openlink.jdbc2.OPLUtility.makeException(OPLUtility.java:56)
> >         at
> > openlink.jdbc2.OPLPreparedStatement.setCharacterStream(OPLPreparedSta
> > tement.java:691)
> >         at testConnect2.main(testConnect2.java:29)

> > Am I doing this right?


> > > At least for Oracle I know 4K limit for method setString().
> > > If your character=4 byte then looks like there is 4K limit
> > > for DB2 also.

> > > There is way to use streams here:

> > > pst = con.prepareSatement(.........?.......);
> > > pst.setCharacterStream(1, new java.io.StringWriter(message) );

> > > (you may hit 32K limit also....)

> > > AlexV



> > > > Hello,

> > > > I'm running java 1.2.2 on aix 4.3.  Using DB2 05.01.0001 with OpenLink
> > > > opljdbc2 driver 3.20.10.22.  Using Jakarta-Tomcat 3.2.1 servlet
> engine,
> > > > default settings.

> > > > I have a column defined in database "table" as MESSAGE LONG VARCHAR.

> > > > "message" is a java String which is 1043 characters long.  Begins with
> > > > "blah, blah".

> > > > I execute:

> > > > sql = "insert into table (MESSAGE) values ('" + message + "')";
> > > > Statement s = dbCon0.createStatement();
> > > > s.setMaxFieldSize(5000);
> > > > ResultSet r = s.executeQuery(sql);

> > > > Ths results in SQL0102N "The string constant beginning with "blah,
> blah"
> > > > is too long.  SQLSTATE=54002.

> > > > Any suggestions on what can I do about this?  Thanks.

> > > > -ron

> > > > --
> > > > Ron Parker
> > > > Software Creations            http://www.scbbs.com
> > > > TradeWinds Publishing         http://www.intl-trade.com
> > > > TradePoint Los Angeles        http://www.tradepointla.org
> > > > SiteDirector Security Server  http://livepublish.scbbs.com
> > > > Civil War Online Library      http://civilwar.scbbs.com

> > --
> > Ron Parker
> > Software Creations            http://www.scbbs.com
> > TradeWinds Publishing         http://www.intl-trade.com
> > TradePoint Los Angeles        http://www.tradepointla.org
> > SiteDirector Security Server  http://livepublish.scbbs.com
> > Civil War Online Library      http://civilwar.scbbs.com

--
Ron Parker
Software Creations            http://www.scbbs.com
TradeWinds Publishing         http://www.intl-trade.com
TradePoint Los Angeles        http://www.tradepointla.org
SiteDirector Security Server  http://livepublish.scbbs.com
Civil War Online Library      http://civilwar.scbbs.com


Mon, 25 Aug 2003 13:44:55 GMT
 
 [ 6 post ] 

 Relevant Pages 

1. String constant too long (SQL0102N)

2. Error SQL0102N String too long

3. Query with long string constant doesn't work

4. String constants longer than 255 characters?

5. Insert a long value ORA-01704: string literal too long

6. Long, long character string

7. Converting long to string and to convert the unix dates in the string to regular dates

8. Converting long to string and to convert the unix dates in the string to regular dates

9. ecpg problem : pre-processor translated long constant to char

10. ecpg problem : pre-processor translated long constant to char

11. Constant declaration for long

12. How to compare a string value measure with constant


 
Powered by phpBB® Forum Software