Solved

java Strings and sql server varchar

Posted on 2003-10-31
5
259 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
convert in derived column 7 30
best counters for cpu high usage 3 33
sql 2014,  lock limit 5 32
transaction in asp.net, sql server 6 33
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

821 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