mercredi 25 novembre 2015

Scanning database table, looking for NULL values in any column and if found, storing only that column in array

I'm trying this but got stuck. This piece of code will scan the table from database (data is of VARCHAR type). It will look one column at a time. If it finds null in a column, it'll store that column entries in an array. The problem is that values are not storing in array. Its output is a blank page. (It's actually a java web application). Kindly give any suggestions.

for(int k = 1; k < totalColumns; k++)   // k = column number
        {
            int i = 0;
            innerwhile:
            while(result.next())
            {
                String value = result.getString(k);
                if(value.equals("null"))
                {
                    result.beforeFirst();

                    while(result.next())    // storing column in array
                    {

                        String tempValue = result.getString(k);
                        if(tempValue.equals("null"))
                        {
                            ; // do nothing because in array I don't need null values



                        }
                        else
                        {

                           rowValues[i] = tempValue;
                           i++;
                        }

                    }
                    i = 0;



                break innerwhile;
                } // end if
            } // end labeled while
            result.beforeFirst();

        }




Aucun commentaire:

Enregistrer un commentaire