Solved

java Strings and sql server varchar

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel conversion issue with Sql server 14 46
SQL Login 17 38
SQL Server - SQL field is defined as text 3 27
Help Extract Specific in SQL 8 21
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

910 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

22 Experts available now in Live!

Get 1:1 Help Now