I just wanted to inform anyone interested that I've been able to
cure my varchar padding problems using a JDBC driver from
BEA Weblogic. The driver name is:
Although this works great, I would still like to try to find a
JDBC or ODBC:JDBC driver which is available under Open Source
or might otherwise be in the Public Domain, but don't have this
varchar padding problem with Prepared Statements.
Anyone know of any other available JDBC drivers I can try?
> My apologies. :)
> I'm using MS SQL as a database and I'm using Sun's jdbc:odbc driver,
> "sun.jdbc.odbc.JdbcOdbcDriver", but I've also tried Microsoft's driver
> "com.ms.jdbc.odbc.JdbcOdbcDriver". With the same results.
> Someone emailed me concerning the possibility of seeing the bug
> detailed at:
> ...but this doesn't seem applicable, as I'm not getting a setString truncated,
> I'm just
> trying to insert a record with over 260 fields, all strings, several of which
> may be as
> long as 40 to 50 characters in length. Since most of them average 10-15
> in length, using a varchar of 60 should allow for the longest records, with
> the extra
> space for a 10 char string not being used or wasted. However, I find that
> a table with 270 fields, each defined as varchar 60, will occupy over 16,200
> (270x60) well exceeding the 8,000 or so maximum for a single row in MS SQL.
> I've been trying to use a Statement instead of PreparedStatement, and
> I have had extreme problems getting it to work with real data, I have
> that the same varchar problem doesn't seem to exist with a JDBC Statement.
> I'm also using JDK v1.2.2 which I don't believe has JDBC 2, so Im
> going to try the latest JDBC 2 version next to see if it helps.
> Anyone else seen this or have any idea what's going on?
> > I really think you'll need to specify which DBMS and especially which JDBC
> > driver you use before you can get a decent answer ;-)
> > Geert 'Darling' Van Damme
> > > I have a very large insert which fails due to the fact that all the
> > >fields are padded to
> > >full varchar size rather than packed to the actual length of the
> > >records.
> > > I'm inserting records into a database and I find that when using
> > >varchar
> > >type fields, so as to conserve space, the records are apparently being
> > >padded
> > >to the full varchar size when created with a PreparedStatement using
> > >JDBC.
> > > For example, if I create a table:
> > > CREATE TABLE TestTable (Field1 varchar(40))
> > >and then do an INSERT:
> > > INSERT INTO TestTable (Field1) VALUES ("Hello World")
> > >. . . I find that if this insert is done with JDBC using a
> > >PreparedStatement, the length of
> > >the resulting record will be 40, not 11. If the same insert is done
> > >using a JDBC Statement, or
> > >manually inserting in an SQL query analyzer, the record length will be
> > >11.
> > > Can anyone tell me why PreparedStatements used in JDBC seem to pad
> > >varchar
> > >records to their full size??? Sort of defeats the purpose of using a
> > >varchar types. :-)
> > > Any clue would be gratefully appreciated.
> > >Alan