Need help Take out the null values from the ResultSet and Create a XML file

hi,
I wrote something which connects to Database and gets the ResultSet. From that ResultSet I am creating
a XML file. IN my program these are the main two classes Frame1 and ResultSetToXML. ResultSetToXML which
takes ResultSet & Boolean value in its constructor. I am passing the ResultSet and Boolean value
from Frame1 class. I am passing the boolean value to get the null values from the ResultSet and then add those
null values to XML File. When i run the program it works alright and adds the null and not null values to
the file. But when i pass the boolean value to take out the null values it would not take it out and adds
the null and not null values.
Please look at the code i am posing. I am showing step by step where its not adding the null values.
Any help is always appreciated.
Thanks in advance.
============================================================================
Frame1 Class
============
public class Frame1 extends JFrame{
private JPanel contentPane;
private XQuery xQuery1 = new XQuery();
private XYLayout xYLayout1 = new XYLayout();
public Document doc;
private JButton jButton2 = new JButton();
private Connection con;
private Statement stmt;
private ResultSetToXML rstx;
//Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
//Component initialization
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
xQuery1.setSql("");
xQuery1.setUrl("jdbc:odbc:SCANODBC");
xQuery1.setUserName("SYSDBA");
xQuery1.setPassword("masterkey");
xQuery1.setDriver("sun.jdbc.odbc.JdbcOdbcDriver");
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
xQuery1.setSql("Select * from Pinfo where pid=2 or pid=4");
jButton2.setText("Get XML from DB");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
catch(java.lang.ClassNotFoundException ex) {
System.err.print("ClassNotFoundException: ");
System.err.println(ex.getMessage());
try {
con = DriverManager.getConnection("jdbc:odbc:SCANODBC","SYSDBA", "masterkey");
stmt = con.createStatement();
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton2_actionPerformed(e);
contentPane.add(jButton2, new XYConstraints(126, 113, -1, -1));
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
void jButton2_actionPerformed(ActionEvent e) {
try{
OutputStream out;
XMLOutputter outputter;
Element root;
org.jdom.Document doc;
root = new Element("PINFO");
String query = "SELECT * FROM PINFO WHERE PID=2 OR PID=4";
ResultSet rs = stmt.executeQuery(query);
/*===========This is where i am passing the ResultSet and boolean=======
===========value to either add the null or not null values in the file======*/
rstx = new ResultSetToXML(rs,true);
} //end of try
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
======================================================================================
ResultSetToXML class
====================
public class ResultSetToXML {
private OutputStream out;
private Element root;
private XMLOutputter outputter;
private Document doc;
// Constructor
public ResultSetToXML(ResultSet rs, boolean checkifnull){
try{
String tagname="";
String tagvalue="";
root = new Element("pinfo");
while (rs.next()){
Element users = new Element("Record");
for(int i=1;i<=rs.getMetaData().getColumnCount(); ++i){
tagname= rs.getMetaData().getColumnName(i);
tagvalue=rs.getString(i);
System.out.println(tagname);
System.out.println(tagvalue);
/*============if the boolean value is false it adds the null and not
null value to the file =====================*/
/*============else it checks if the value is null or the length is
less than 0 and does the else clause in the if(checkifnull)===*/
if(checkifnull){ 
if((tagvalue == null) || tagvalue.length() < 0 ){
users.addContent((new Element(tagname).setText(tagvalue)));
else{
users.addContent((new Element(tagname).setText(tagvalue)));
else{
users.addContent((new Element(tagname).setText(tagvalue)));
root.addContent(users);
out=new FileOutputStream("c:/XMLFile.xml");
doc = new Document(root);
outputter = new XMLOutputter();
outputter.output(doc,out);
catch(IOException ioe){
System.out.println(ioe);
catch(SQLException sqle){

Can someone please help me with this problem
Thanks.

Similar Messages

  • Eliminating the null values from popup list item

    Dear All,
    i create a popup list,at runtime it shows a null blank value among the values i specified while the combo box is not,
    i want to eleminate the blank null value from the popup list.
    Need Help.
    Thanks & Regards.

    Okay,
    i create a popup list, populate it in runtime with create_group_from_query builtin.
    now when i run the form and click the list item, it display a null value among the other values which are
    return from the create_group_from_query .
    the procedure is below
    procedure Department_proc is
    rg recordgroup;
    n number;
    begin
    remove_record_group('RG');------  this is another procedure which checks for Record group existance and remove it.
    rg=:=create_group_from_query('RG4','SELECT NAME,TO_CHAR(DEPT_ID) FROM TAB_DEPT_SECTION
    UNION
    SELECT '||'''All Departments'''||'as name,'||'''0'''||' as name from dual');
    n:=populate_group(rg4);
    populate_list('control_block.department',rg4);
    end;
    it display a null value among the other values for the first time is run the form,but when i click it and select a value from it
    and the onward click dont show the null value.i want to eleminate the null value even for the first time when the user run the
    from.
    Best Regards

  • Book out the Consumption value from the planned consumption

    Hello everybody,
    i am going to develope a consumption report, is there a BABI or Something Like This that  available to book out the Consumption value from the planned consumption? (to unplanned consumption)
    Thanks
    Best regards.
    DANI.

    I am currently working on a SQVI report just a prototype prior to having the programmer create an ABAP report. The trouble I am having is truly understanding how SAP tabulates the consumption. We are putting significant effort into this report and will let you know the results.

  • How can I access the Attribute Values from the Search Region

    Hi all,
    I have a table which contains Company id, department id, and PositonId. For a particular Company and Department there may be multiple records.
    I have to pupulate a table which contains the position and other details that comes under a particular Department and Position based on the selection in the Three comboBoxes.
    Also I have to populate a select many Shuttle to add new postions and records under a particular Department.
    I created a query panel *(Search Region)* for the serch and a table to display the data. That is working fine.
    Now the issue is I am using a view criteria to populate the shuttle with two bind variables ie, DepartmentId and CompanyId.
    If the serach will return a resuktant set in the table it will also pupulate the correct records, otherwise ie, if the if the serch result is empty the corresponding iterator and the attribute is setting as null.
    SO I want to access the attribute values from the Search Region itsef to populate the shuttle.
    I don't know how can I access the data from the Search Region.
    Please Help.
    Regards,
    Ranjith

    you could access the parameters entered in search region by the user as follows:
    You can get handle to the value entered by the user using queryListener method in af:query.
    You can intercept the values entered as described
    public void onQueryList(QueryEvent queryEvent) {
    // The generated QueryListener replaced by this method
    //#{bindings.ImplicitViewCriteriaQuery.processQuery}
    QueryDescriptor qdes = queryEvent.getDescriptor();
    //get the name of the QueryCriteria
    System.out.println("NAME "+qdes.getName());
    List<Criterion> searchList = qdes.getConjunctionCriterion().getCriterionList();
    for ( Criterion c : searchList) {
    if (c instanceof AttributeCriterion ) {
    AttributeCriterion a = (AttributeCriterion) c;
    a.getValues();
    for ( Object o : a.getValues()){
    System.out.println(o.toString());
    //call default Query Event
    invokeQueryEventMethodExpression("#{bindings.ImplicitViewCriteriaQuery.processQuery}",queryEvent);
    public void onQueryTable(QueryEvent queryEvent) {
    // The generated QueryListener replaced by this method
    //#{bindings.ImplicitViewCriteriaQuery.processQuery}
    QueryDescriptor qdes = queryEvent.getDescriptor();
    //get the name of the QueryCriteria
    System.out.println("NAME "+qdes.getName());
    invokeQueryEventMethodExpression("#{bindings.ImplicitViewCriteriaQuery.processQuery}",queryEvent);
    private void invokeQueryEventMethodExpression(String expression, QueryEvent queryEvent){
    FacesContext fctx = FacesContext.getCurrentInstance();
    ELContext elctx = fctx.getELContext();
    ExpressionFactory efactory = fctx.getApplication().getExpressionFactory();
    MethodExpression me = efactory.createMethodExpression(elctx,expression, Object.class, new Class[]{QueryEvent.class});
    me.invoke(elctx, new Object[]{queryEvent});
    Thanks,
    Navaneeth

  • How can i get the all values from the Property file to Hashtable?

    how can i get the all values from the Property file to Hashtable?
    ok,consider my property file name is pro.PROPERTIES
    and it contain
    8326=sun developer
    4306=sun java developer
    3943=java developer
    how can i get the all keys & values from the pro.PROPERTIES to hashtable
    plz help guys..............

    The Properties class is already a subclass of Hashtable. So if you have a Properties object, you already have a Hashtable. So all you need to do is the first part of that:Properties props = new Properties();
    InputStream is = new FileInputStream("tivoli.properties");
    props.load(is);

  • Accessing the email value from the iPhone AddressBook

    Need some help getting the email value from the AddressBook. This is what I have so far ...
    Used to open up the picker and limit to email only
    -(void) browseButtonPressed:(id)sender
    ABPeoplePickerNavigationController* controller = [[ABPeoplePickerNavigationController alloc] init];
    controller.peoplePickerDelegate = self;
    NSNumber* emailProp = [NSNumber numberWithInt:kABPersonEmailProperty];
    controller.displayedProperties = [NSArray arrayWithObject:emailProp];
    controller.navigationBar.tintColor = [UIColor blackColor];
    [self presentModalViewController:controller animated:YES];
    The delegate method in the same class
    - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker
    shouldContinueAfterSelectingPerson:(ABRecordRef)person
    property:(ABPropertyID)property
    identifier:(ABMultiValueIdentifier)identifier
    NSString *email = (NSString *)ABRecordCopyValue(person, kABPersonEmailProperty);
    NSLog(@"selected person: %@", email);
    [[peoplePicker parentViewController] dismissModalViewControllerAnimated:YES];
    return NO;
    The NSLog prints the following ...
    selected person: <NSCFType: 0x1d81c0>
    Any idea why it's not printing a string rather I am getting NSCFType ?

    Great Post. One of the few times that I was able to come to a conclusion about the code I need. Here is an example of the delegate method in reference to getting the email address.
    - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
    ABMultiValueRef emails = ABRecordCopyValue(person, property);
    CFStringRef email = ABMultiValueCopyValueAtIndex(emails, identifier);
    NSLog( (NSString *) email);
    self.receiverEmail.text = (NSString *) email;
    [self.tabBarController dismissModalViewControllerAnimated:YES];
    return NO;
    }

  • "An error occurred while attempting to retrieve the KPI value from the list"

    Hi all.
    when I used KPI, this error occured:
    An error occurred while attempting to retrieve the KPI value from the list
    what happened?
    any suggestion.
    thanks.

    Hello,
    Unfortunatly, I don't have the option to re-create my SP list.  I have created my KPI list in the same site as the targeted list.  I have made all items available in the list view, I've tried several different list views, I still get the
    An error occurred while attempting to retrieve the KPI value from the list.
    message. 
    I am at a loss here, I've search the internet high a low and haven't found any helpful info. 
    In MOSS 2007 I've created a list with about 24 columns.  I need a KPI based on one of the columns.  I've tried to creat a view with that one column, I've tried to creat a view with all columns
    and make it the defualt column...  I don't know what else to try here.
    Any help would be very appriciated!
    Cheers,
    ~Bryan

  • How to put the null value at the last of  a select list

    Hello,
    I have a select list with a null value, I want the null value to be the last value in the list. It always appears in the top of the list, Desc and Asc order is not working.
    Thank you in advance!
    Edited by: Najla on Apr 1, 2013 10:37 PM

    Hi,
    Edited by: Howard (... in Training) on Apr 2, 2013 1:xx PM
    The statement - I don't think it is possible to arrange the order of the null option in a select list.- is close. You can't control the order of the Null value if you add the Null value through the GUI. However, it can be added and controlled as part of a SELECT ...
    One way is to add NULL to the "SELECT". Here the Yes/No are hard-coded but they could have been selected from a table:
    select d, r from
    select 'YES' d, 'Y' r from dual
      union all
    select 'No' d, 'N' r from dual
      union all
    select Null d, '<Null>' r from dual
    ) order by 1 desc NULLS lastHoward

  • Retrieving  the score value from the captivate into flash

    Hi,
    We have used Captive 2 to built course & publishing it as
    a non e-learning output
    and loading the published swf file in custom built flash
    movie (wrapper).
    We have accessed some of the captivate variables to control
    the captivate swf.
    Does anyone know how to retrieve the score value from the
    captivate into flash ?
    Thanks
    Regards
    Chetan

    Hello,
    Use the Object Browser in .NET and search on "Summaryinfo" and you'll find the API to use.
    Thank you
    Don

  • I lost my ipod I really need help to find it. Im from other country and i cant buy another one. Is not connected to internet

    I lost my ipod I really need help to find it. Im from other country and i cant buy another one. Is not connected to internet

    There is nothing anyone can do.
    Sorry.
    You will have to keep looking for it

  • ITunes producer error 3000 character content of element "file_name" invalid. Can anyone help me out? This happens when i try and submit an epub file, i haven't had this before.

    Can anyone help me out? This happens when i try and submit an epub file, i haven't had this before. "iTunes producer error 3000 character content of element "file_name" invalid."
    This is the full message

    You really need to put your codes between the
    [\code] tags
    see http://forum.java.sun.com/features.jsp#Formatting
    for more infoCode tags might make it look a little better, but there's still too darn much code. We're volunteers, after all. It'd be a lot of work to review all of this stuff. Can you demonstrate your problem with something smaller? Learn out how to do a combo box with just a page or two and then appy that to your big problem. That's how I'd do it. - MOD

  • How to avoid the null values from xml publisher.

    I am creating a report which have the claim numbers with the values CLA001,CLA111,null, null . when i preview my report it is showing some spaces for null values also. How can i avoid the spaces from the report.
    I am giving for loop for the claim numbers in the template.
    <?for-each:ROW?> <?sort:CLAIMNUMBER;'ascending';data-type='text'?>
    <?CLAIMNUMBER?>
    <?end for-each?>
    Please help me out to solve this problem.
    Thanks,
    vasanth.

    Hi Sheshu,
    According to your description, you are experiencing the null values and infinity values when browser the calculated measure, right?
    Based on my research, the issue is caused by that dividing a non-zero or non-null value by zero or null. In this cases, we need to check for division by zero to avoid this situation. Here is the sample query for you reference.
    IIF(
    Measures.[Measure B]=0,null,
    Measures.[Measure A] / Measures.[Measure B]
    If you have any questions, please feel free to ask.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Need to get the selected values from the selectManyShuttle

    Hi,
    I am using ADF11g newer version.
    I have a selectManyShuttle and a command button. Need to insert all the selected values on the right hand side of the selectManyShuttle into a database table.
    I created the selectManyShuttle with the values. Need help in getting the values on the right hand side.
    <af:selectManyShuttle value="#{bindings.UserMgmtVO1.inputValue}"
    id="sms2">
    <f:selectItems value="#{bindings.UserMgmtVO1.items}"
    id="si6"/>
    </af:selectManyShuttle>
    Any sample code or link is really appreicated.
    Thanks

    Thanks for the reply.
    I am using a View Object and I dropped it as SelectManyShuttle
    <af:selectManyShuttle value="#{bindings.UserMgmtVO1.inputValue}"
    id="sms2"
    valueChangeListener="#{POBacking.getSelectedValues}"
    valuePassThru="true"
    autoSubmit="true">
    <f:selectItems value="#{bindings.UserMgmtVO1.items}"
    id="si6"/>
    </af:selectManyShuttle>
    public void getSelectedValues(ValueChangeEvent valueChangeEvent) {
    System.out.println("Testing Shuttle");
    ArrayList list = new ArrayList(Arrays.asList(valueChangeEvent.getNewValue()));
    String val = "";
    String sqlStmt = "";
    try {
    if (list != null) {
    for (int i = 0; i < list.size(); i++) {
    int l = list.size() - 1;
    val = list.get(l).toString(); //returns , delimited string
    System.out.println(" value:" + val);
    if (val != null) {
    val = val.replaceAll("[\\[\\]]", ""); //remove []
    StringTokenizer st = new StringTokenizer(val, ",");
    int nto = st.countTokens();
    for (int j = 0; j < nto; j++) {
    String users = st.nextToken().trim();
    System.out.println("Users:" + users);
    //sqlStmt = " update xxpp_project_clip set clip_status='true', clip_seq = "+j * 10+
    // " where project_id = "+rHdr.getAttribute("ProjectId") +
    // " and clip_name ='"+ clip_Name +"'";
    //System.out.println("sqlStmt:" + sqlStmt);
    //stmt.executeUpdate(sqlStmt);
    //am.getDBTransaction().commit();
    //if (stmt != null)
    // stmt.close();
    // am.getDBTransaction().commit();
    } catch (Exception ex) {
    ex.printStackTrace();
    I don't see the values in the list.
    I gets printed as
    value:[Ljava.lang.Integer;@1b10691
    Users:Ljava.lang.Integer;@1b10691
    how to get the individual values in the list?
    Thanks
    Saru

  • To extract null Values from the source in Infopackage selections - Very Urg

    Hi All,
    I need to pull the data which has null values from source. I tried to write routine by giving l_t_range-low = '' , space. nothing is working.
    Please guide me with sample code.
    Very Urgent.
    Regards
    Mano

    Hi Mario.
    Assuming that you want to avoid uploading of records having
    zero for a keyfigure:
    Create a startroutine for transfer rules and add this coding:
    DELETE DATAPAK WHERE VALUE = '0'.
    OR
    LOOP AT DATAPAK.
    IF DATAPAK-VALUE = 0..
    DELETE DATAPAK.
    ENDIF.
    ENDLOOP.
    'VALUE' represents the fieldname in transferstructure
    Please let me know if i misundersttod the issue.
    Regards
    Joe

  • Not to display the null values from data base

    Hiiii.
    In a jsp file i have ten check boxes.The jsp file is mapped to a servlet file for parameter requesting and to
    store it in DB.
    The unchecked box values has null values.All the values are store in a Mysql DB table.
    Again i have to display it in a jsp page from table.
    The problem am facing was,how can i display only the values in a row.it must not display the null values and the crresponding column name.
    Or any other way is their like below
    How i can retrieve only the selected check boxes from tht jsp file.and store in backend.
    Thanks in Advance
    regards,
    satheesh kannan

    Here is a rough example that may give you some ideas:
    On the JSP page:
    <%if(myData.getFirstName()!=null){%>
    Your First Name'
    <input type="text" name="firstName" value="<%=myData.getFirstName()%>">
    <%}%>
    In the servlet:
    String firstName= request.getParameter("firstName");
    if(firstName!=null){
    //write it to the database
    }

Maybe you are looking for

  • Wireless Mu

    I have a problem with installing the soundblaster wireless music software. Every time I try to install it it get the error message: Error Number:0x8004020 Description: An event was unable to invoke anyof the subscribers Setup will now terminate I'm r

  • Favorites menu was on my homepage and is now gone. How do I get it back

    On my homepage, Firefox. I had a favorites menu on the left hand side. Now it is gone. I can get my bookmarks from toolbar but really liked it on the screen for easier access. Hw do I get it back?

  • Good, easy, reliable CAPTCHA for PHP form

    Does anyone know of a reliable (and easy to impliment) CATPCHA for PHP forms? My website is having the hell spammed out of it! There are loads out there, but I need a recommended one - and one that a novice like me can install!

  • Rtmp not connecting, sample video not streaming

    I am developing an application in Flash that runs locally and it uses FMS 4.01, locally. I have been using adobe FMS 4.01 for months with no problem. Today I cannot connect to my server and I cannot even play the sample video on the Flash Media Serve

  • Why does 3g data eats up my minutes?

    need help on when my iPhone 3g data is on consume all my load of minutes?