Solved

java Strings and sql server varchar

Posted on 2003-10-31
5
264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

631 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