Link to home
Start Free TrialLog in
Avatar of joannape
joannape

asked on

JDBC VARCHAR problem

I am inserting data into an SQL Server database from a coarse-grained EJB. When a string is inserted into a VARCHAR field in the database, the string is taking up the full length of the VARCHAR field, rather than just the length of the string - any ideas?

This problem does not occur with my fine-grained EJBs which use stored procedures to insert data.

Thanks in advance.
Avatar of jerelw
jerelw

Use ResultSetMetaData to get your max sizes, and then truncate your varchar to to 'fit' in your field.

Or use static longs to limit your data to the size of your fields.
ASKER CERTIFIED SOLUTION
Avatar of Neutron
Neutron

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of girionis
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- points to Neutron

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer