472,779 Members | 2,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

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 33390
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.