• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Row Size Problem

 
Nanchun Lin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got following exception when inserting a record in a table using PreparedStatement:
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot create a row of size 8192 which is greater than the allowable maximum of 8060.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:2533)
The code likes:
String strSQL = "INSERT INTO Announce (Title, Content, AnnounceType) VALUES (?, ?, ?)";
PreparedStatement ps = con.prepareStatement(strSQL);
ps.setString(1, "Test");
ps.setString(2, "Hello");
ps.setString(3, "School");
ps.execute();
The Announce table likes:
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[Title] [nvarchar] (50) NULL ,
[Content] [nvarchar] (4000) NULL ,
[AnnounceType] [nvarchar] (20) NULL ,
It works if using Statement to insert the record. But I prefer PreparedStatement because it is easy to handle single quotation problem. Can anyone help me solve this problem?
Thanks.
Nanchun
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Content] [nvarchar] (4000) NULL ,
I believe PreparedStatement.setString() has a limit to the length of the String to be set. In some databases you can get around this limit by streaming the text to/from the database:
just a guess, not too familiar SQL server drivers
Jamie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic