JDBC and getting around the 256 character insert limit...
Posted in 1999
Topics: Connectivity: ODBC / JDBC / .NET, Java & JDBC Development
Hi folks, I will also post this message in the Java newsgroups just in case people don't read it here. Basically, this has to do with the IDIOTIC 256 character insert limit on literally quoted strings in Informix. For those using the JDBC drivers, and doing a literal insert, you have NO DOUBT come across this error. Hopefully, Informix will heed the complaints of its developers and lift this limit. Its really a pain in the ass. I am including a Java code snippet which will get around this limit using prepared statements. Please share it with everyone you can. Its a pain in the ass solution, but it works. Here it is. String longString1 = "<very long string here>"; String longString2 = "<very long string here>"; PreparedStatement pstmt = null; try { pstmt = connection.prepareStatement("insert into mytable values (?, ?)"); pstmt.setString(1, longString1); pstmt.setString(2, longString2); pstmt.executeUpdate(); } catch (SQLException sqle) { sqle.printStackTrace(); } finally { pstmt.close(); } That's it! I've not stumbled across anything new here. But I have scoured Informix's website and all the newsgroups and I've only seen Perl-based / DBI solutions. Here's one for the JDBC developers. -- Rick