Loading ...
Sorry, an error occurred while loading the content.

EmtyStringIsNull Issue

Expand Messages
  • aaa7u
    Hi, I am using the EmptyStringIsNull option, however when I have an empty string tag such as of data type integer, numeric, or date I get the
    Message 1 of 2 , Jun 20, 2006
    • 0 Attachment
      Hi,

      I am using the EmptyStringIsNull option, however when I have an empty
      string tag such as <DataCount/> of data type integer, numeric, or date
      I get the following error:

      java.lang.NullPointerException
      at java.text.DecimalFormat.parse(DecimalFormat.java:1217)
      at java.text.NumberFormat.parse(NumberFormat.java:307)
      at
      org.xmlmiddleware.conversions.formatters.NumberFormatter.parse(NumberFormatter.java:76)
      at
      org.xmlmiddleware.xmldbms.DOMToDBMS.setPropertyColumn(DOMToDBMS.java:1090)
      at
      org.xmlmiddleware.xmldbms.DOMToDBMS.processProperty(DOMToDBMS.java:807)
      at
      org.xmlmiddleware.xmldbms.DOMToDBMS.processChild(DOMToDBMS.java:685)
      at
      org.xmlmiddleware.xmldbms.DOMToDBMS.processChildren(DOMToDBMS.java:630)
      at
      org.xmlmiddleware.xmldbms.DOMToDBMS.processClassRow(DOMToDBMS.java:544)
      at
      org.xmlmiddleware.xmldbms.DOMToDBMS.processRoot(DOMToDBMS.java:447)
      at
      org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:368)
      at
      org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:317)
      at
      org.xmlmiddleware.xmldbms.tools.Transfer.storeDocumentInternal(Transfer.java:845)
      at
      org.xmlmiddleware.xmldbms.tools.Transfer.storeDocument(Transfer.java:484)
      at sorts_rcv.Sorts_Rcv.ProcessFiles(Sorts_Rcv.java:275)
      at sorts_rcv.Sorts_Rcv.main(Sorts_Rcv.java:82)

      I have no issue with empty tags representing String fields and my XML
      processing into the database if I remove the empty tags. I have no
      control over the XML-Schema so I can not remove the empty tags. Does
      anyone know what my problem might be? Thanks
    • Ronald Bourret
      Congratulations! It looks like you re the first person to use EmptyStringIsNull with anything other than strings :) In the process, you ve found a bug... To
      Message 2 of 2 , Jun 21, 2006
      • 0 Attachment
        Congratulations!

        It looks like you're the first person to use EmptyStringIsNull with
        anything other than strings :) In the process, you've found a bug...

        To fix this, change DOMToDBMS.setPropertyColumn() to the following:

        /**
        * Set the value for column
        */
        private void setPropertyColumn(Row row, PropertyMap propMap, Node node)
        throws XMLMiddlewareException
        {
        Column column;
        StringFormatter formatter;
        String nodeValue;
        Object value;

        column = propMap.getColumn();

        // Get the node value (a string).

        nodeValue = getNodeValue(node, propMap.containsXML());


        if (nodeValue != null)
        {
        // If the node value is non-null, parse it with the column's
        // StringFormatter. The result is an Object of the type
        corresponding
        // to the column's SQL type.

        formatter = column.getFormatter();
        value = formatter.parse(nodeValue, column.getType());
        }
        else
        {
        // If the node value is null, don't format it. Instead, just
        set the
        // value to null. Note that this code is executed only when
        EmptyStringIsNull
        // is true, which is the only time getNodeValue returns a
        null. (The other
        // way to insert a null into the database is when no node
        exists, but in
        // that case, this method is never executed.)

        value = null;
        }

        // Set the column value to the parsed value.

        row.setColumnValue(column, value);
        }

        -- Ron

        aaa7u wrote:
        > Hi,
        >
        > I am using the EmptyStringIsNull option, however when I have an empty
        > string tag such as <DataCount/> of data type integer, numeric, or date
        > I get the following error:
        >
        > java.lang.NullPointerException
        > at java.text.DecimalFormat.parse(DecimalFormat.java:1217)
        > at java.text.NumberFormat.parse(NumberFormat.java:307)
        > at
        > org.xmlmiddleware.conversions.formatters.NumberFormatter.parse(NumberFormatter.java:76)
        > at
        > org.xmlmiddleware.xmldbms.DOMToDBMS.setPropertyColumn(DOMToDBMS.java:1090)
        > at
        > org.xmlmiddleware.xmldbms.DOMToDBMS.processProperty(DOMToDBMS.java:807)
        > at
        > org.xmlmiddleware.xmldbms.DOMToDBMS.processChild(DOMToDBMS.java:685)
        > at
        > org.xmlmiddleware.xmldbms.DOMToDBMS.processChildren(DOMToDBMS.java:630)
        > at
        > org.xmlmiddleware.xmldbms.DOMToDBMS.processClassRow(DOMToDBMS.java:544)
        > at
        > org.xmlmiddleware.xmldbms.DOMToDBMS.processRoot(DOMToDBMS.java:447)
        > at
        > org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:368)
        > at
        > org.xmlmiddleware.xmldbms.DOMToDBMS.storeDocument(DOMToDBMS.java:317)
        > at
        > org.xmlmiddleware.xmldbms.tools.Transfer.storeDocumentInternal(Transfer.java:845)
        > at
        > org.xmlmiddleware.xmldbms.tools.Transfer.storeDocument(Transfer.java:484)
        > at sorts_rcv.Sorts_Rcv.ProcessFiles(Sorts_Rcv.java:275)
        > at sorts_rcv.Sorts_Rcv.main(Sorts_Rcv.java:82)
        >
        > I have no issue with empty tags representing String fields and my XML
        > processing into the database if I remove the empty tags. I have no
        > control over the XML-Schema so I can not remove the empty tags. Does
        > anyone know what my problem might be? Thanks
      Your message has been successfully submitted and would be delivered to recipients shortly.