473,473 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

convert null into to null string

I have a sql resultset called columns. When I convert an integer
column to string that is a NULL it converts to zero. How can I get it
to convert to null??

String x;
x = Integer.toString(columns.getInt("Integercolumnname "));

if x is null it will be converted to '0'. I want it converted to
null.
Jul 17 '05 #1
4 33538
If I understand you correctly it should be something like this:

String x = (null == columns.getInt("Integercolumnname"))
? null
: Integer.toString(columns.getInt("Integercolumnname "))
;

"DiggidyMack69" <Di***********@hotmail.com> wrote in message
news:c8*************************@posting.google.co m...
I have a sql resultset called columns. When I convert an integer
column to string that is a NULL it converts to zero. How can I get it
to convert to null??

String x;
x = Integer.toString(columns.getInt("Integercolumnname "));

if x is null it will be converted to '0'. I want it converted to
null.

Jul 17 '05 #2
It looks like all your can do is test for null by using the
getObject("columnName") method. According to the JavaDoc, this will
return null if there isn't a value in the field. I'm surprised there
isn't an isNull("columnName") method.

-Nathan

Di***********@hotmail.com (DiggidyMack69) wrote in message news:<c8*************************@posting.google.c om>...
I have a sql resultset called columns. When I convert an integer
column to string that is a NULL it converts to zero. How can I get it
to convert to null??

String x;
x = Integer.toString(columns.getInt("Integercolumnname "));

if x is null it will be converted to '0'. I want it converted to
null.

Jul 17 '05 #3
There is allways the wasNull() method call. If the converted value returns 0
this can allways be cahnged to some different value if the value 'wasNull'.
But unfortunatelly this value has to be fetched first :)

Rein

"Nathan Zumwalt" <na*****@hotmail.com> wrote in message
news:52**************************@posting.google.c om...
It looks like all your can do is test for null by using the
getObject("columnName") method. According to the JavaDoc, this will
return null if there isn't a value in the field. I'm surprised there
isn't an isNull("columnName") method.

-Nathan

Di***********@hotmail.com (DiggidyMack69) wrote in message

news:<c8*************************@posting.google.c om>...
I have a sql resultset called columns. When I convert an integer
column to string that is a NULL it converts to zero. How can I get it
to convert to null??

String x;
x = Integer.toString(columns.getInt("Integercolumnname "));

if x is null it will be converted to '0'. I want it converted to
null.

Jul 17 '05 #4
"Reinaerde" <re*******@yahoo.com> wrote in message news:<3f***********************@news.xs4all.nl>...
If I understand you correctly it should be something like this:

String x = (null == columns.getInt("Integercolumnname"))
? null
: Integer.toString(columns.getInt("Integercolumnname "))
;

"DiggidyMack69" <Di***********@hotmail.com> wrote in message
news:c8*************************@posting.google.co m...
I have a sql resultset called columns. When I convert an integer
column to string that is a NULL it converts to zero. How can I get it
to convert to null??

String x;
x = Integer.toString(columns.getInt("Integercolumnname "));

if x is null it will be converted to '0'. I want it converted to
null.


Unfortunately if I do that the servlet won't compile. it tells me that
basically an int cannot be null. im going to play with the getObject
though.
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: BlueDragon | last post by:
I don't know enough math to demonstrate that any numerical operation with a null should yield a null; although I would guess that it's true. I just don't buy it, however, when dealing with strings...
1
by: Swarup | last post by:
I am reading a file (txt, xml, gif, ico, bmp etc) byte by byte and filling it into a byte arry. Now i have to convert it into a string to store it in the database. I use...
6
by: JKop | last post by:
What's the best method to use? I've searched the web a bit and all I've come up with is "sprintf". Also, for the converse, ie. string to double, is "atof" the way to go? Kind Regards, ...
8
by: FrzzMan | last post by:
How to convert back a string that have converted to byte using System.Text.Encoding.UTF8.GetBytes() string StringData = "This is a string"; byte ConvertedString =...
5
by: moondaddy | last post by:
How do I get the string representation of an int? for example int var1 = 2; string var2 = var1.ToString; I'm wanting var2 to be "2" I get the compile error: Error 1 Cannot convert...
0
by: Leite33 | last post by:
Hello I am rookie in learning C++ Builder 6. I try to make an application for storing data and especially pictures. So i try to connect C++Builder 6 and Microsoft SQL Server 2000. I use 4 C++...
3
by: bussiere maillist | last post by:
i've got a very long string and i wanted to convert it in binary like string = """Monty Python, or The Pythons, is the collective name of the creators of Monty Python's Flying Circus, a British...
2
by: Joah Senegal | last post by:
Hello I need to convert a chat to a string... but I don't know how to do this. i;ve searched the internet but I've only find some code to convert char * to string or char to string.... but I...
8
by: =?Utf-8?B?UmljYXJkbyBRdWludGFuaWxsYQ==?= | last post by:
i need to convert data from string to nibble wich (nibble is a four bits representation) As example i have the following code string data1 = "12345678"; so ¿how can i convert this data...
3
by: mamul | last post by:
Hi please some one can help me. how to convert char * to string? i have take char *argv from command line and want to pass to a function as string object(string str) i want to first convert argv...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.