Home arrow static arrow Java Programming [Archive] - Detect null in MYSQL
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Detect null in MYSQL
This topic has 4 replies on 1 page.

Posts:9
Registered: 8/8/04
Detect null in MYSQL  
Aug 9, 2004 3:56 AM



 
I have a problem like this;

There's a listbox which filled up which data when the page initialized.The

data source from a column containing null value in mysql datebase.I want to

make a javascript function to delete the null item of the listbox.But I

don't down how to detect the null item. Three ways I made were fail.

1 if(document.formName.listBoxName.value=="")

2 if(document.formName.listBoxName.value.length<=4)

3 if(document.formName.listBoxName.value==null)

If someone here meet this problem before ,Please tell me the solution to

handle it.Thx!
 

Posts:21,718
Registered: 98-02-20
Re: Detect null in MYSQL  
Aug 9, 2004 4:40 AM (reply 1 of 4)



 
Use the method java.sql.ResultSet.wasNull().

Doing this in javascript is a very bad idea. Database access is a middle tier activity. The middle tier object that performs the query should iterate through the ResultSet and load its results into data structures that your JSP can display and then close the ResultSet right away. That's where you should be calling wasNull(), not in a JSP or javascript function.

%
 

Posts:21,718
Registered: 98-02-20
Re: Detect null in MYSQL  
Aug 9, 2004 4:41 AM (reply 2 of 4)



 
Don't cross-post:

http://forum.java.sun.com/thread.jsp?thread=545004&forum=31&message=2649954
http://forum.java.sun.com/thread.jsp?thread=544994&forum=48&message=2649876

%
 

Posts:9
Registered: 8/8/04
Re: Detect null in MYSQL  
Aug 9, 2004 4:45 PM (reply 3 of 4)



 
I know method java.sql.ResultSet.wasNull().
but I can't do that ,Because I'm making three interactive listboxes. The data filled in these three listboxes source from three columns ,such as
column1 column2 column3

Asia null null
Asia Japan null
Asia Japan Tokyo
Asia China null
Asia China BeiJing
Europe null null
Europe France null
Europe France Paris
Europe Britain London
Europe Britain Liverpool

the data of column1 will fill into list1 ,the data of column2 will fill into list2,and so on ,when I click item of asia in list1 the list2 will show two items "Japan" and "China" .and then ,when i click China ,the list3 will show BeiJing .SO ,you see? Beacuse the items of list2 and list3 are created by the items of list1,so I can't adopt the isNull() to delete the null item.
 

Posts:21,718
Registered: 98-02-20
Re: Detect null in MYSQL  
Aug 9, 2004 6:38 PM (reply 4 of 4)



 
I'd cache values in the JSP session and do it with JSTL before I'd do it with javascript. That's not my first option.

%
 
This topic has 4 replies on 1 page.