Solved

java Strings and sql server varchar

Posted on 2003-10-31
5
257 Views
Last Modified: 2008-02-01
i use visual age for java 3.5
i have a java program that inserts some values in a database on sql server
i insert the values using an object of type "com.ibm.ivj.db.uibeans.Modify"

the problem is that the values of type String are concatenated with spaces when i insert them in fields of type varchar in the sql server
0
Comment
Question by:eng_mohamed_said80
5 Comments
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 63 total points
ID: 9657312
sounds like your JAVA string is being defined with the spaces
or the assignment isn't calculating the correct length...
0
 
LVL 22

Assisted Solution

by:CJ_S
CJ_S earned 62 total points
ID: 9657320
That is because the ANSI_PADDING is turned on by default on varchar columns. The nvarchar datatype does not pad your string.

You can turn off ANSI_PADDING by using the following command:
SET ANSI_PADDING OFF

However, it is recommended to keep the ANSI_PADDING turned on when creating indexes on computed columns.
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9658752
CJ_S is absolutely right. You find out what the current setting is by running

SELECT DATABASEPROPERTYEX('DatabaseName', 'IsAnsiPaddingEnabled')

Return Values are,
1 = TRUE
0 = FALSE
NULL = Invalid input
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now