• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Row Size Problem  RSS feed

 
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
 
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
Boost this thread!