Why are all the events in the XML SAX parser not activated?

Hi everyone,
I have written a mini server that parses XML files into SQL queries.
Below is a segment of my code;
          try          {                                                       
               Class.forName( JDBC_DRIVER );
               myConnection = DriverManager.getConnection( DATABASE_URL, "username", "password");                                                  
               EventXMLParser myEXP = new EventXMLParser(directory, myConnection);
               File[] xmlFiles = directory.listFiles();
               for (File xmlFile : xmlFiles)               {     
                    myEXP.XMLtoDB(xmlFile);
                    outWriter.println("File:" + xmlFile.getName() + " DONE");
          } catch (SQLException e)     {
               System.err.println("SQLException for establishing connection");
               e.printStackTrace();
          } catch (ClassNotFoundException e)     {
               System.err.println("CLASS NOT FOUND EXCEPTION HERE");
               e.printStackTrace();
          } catch (Exception e)     {
               System.err.println(e);
               e.printStackTrace();
          finally {
               outWriter.println("PARSING COMPLETED");
               outWriter.close();
     }Where the constructor EventXMLParser constructs the following:
     public EventXMLParser(File path, Connection connection)     {
          super();
          try     {
               this.XMLpath = path;
               this.db_connection = connection;
               this.xr = XMLReaderFactory.createXMLReader();
               this.XMLSAXhandler  = new DefaultHandler(); //create a new own handler
               this.xr.setContentHandler(XMLSAXhandler);
               this.xr.setErrorHandler(XMLSAXhandler);
               //System.out.println("DEBUG: db_connection is " + db_connection.toString());
          catch (Exception e)     {
               System.out.println("Constructor Error!");
               e.printStackTrace();
     }Below are all my helper methods within EventXMLParser.java
     public void XMLtoDB(String XMLpath) throws Exception  {
          try     {
               //Input
               System.out.println("XMLpath is : " + XMLpath);
               /*FileReader r = new FileReader(XMLpath); debug
               InputSource in = new InputSource(r);
               xr.parse(in);
               xr.parse(XMLpath);
               /* Note that while parsing, the end of each event, </event>
                * will trigger sendSQL to execute the query on the database
          catch (Exception e)     {
               throw new Exception("Error with XMLtoDB!! Exception: " + e);
     public void sendSQL(Event event, Connection sql_connection) throws SQLException     {
               //JDBC part
               try     {
                    System.err.println("DEBUG sendSQL");
                    Statement sql_statement = sql_connection.createStatement();
                    ResultSet resultSet = sql_statement.executeQuery( event.toSQL() );
               catch (SQLException e)     {
                    e.printStackTrace();
     /* Parsing XML
      * From here onwards it's all designed for the SAX Parsing with different event calling methods
     public void startDocument()     {
          System.err.println("Start Document");
     public void endDocument()     {
          System.err.println("End Document");
     public void startElement(String uri, String name, String qName, Attributes atts)     {
          CurrentElement= name;
          System.out.println("This is parsing");
     public void characters(char ch[], int start, int length)     {
          SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
          StringBuffer sb = new StringBuffer();
          for (int i = start; i < start + length; i++)     
               sb.append(ch);
          String content = sb.toString();
          if (CurrentElement.equals("eid"))
               temp.setEventID( (Integer.valueOf(content)).intValue() ) ;
          else if (CurrentElement.equals("sd"))
               temp.setShort_description(content);
          else if (CurrentElement.equals("ld"))
               temp.setLong_description(content);
          else if ( (CurrentElement.equals("dt")))
               temp.setDate_Time( formatter.parse(content, new ParsePosition(0)) );
          else if (CurrentElement.equals("repeat"))
               temp.setRepeat_pattern( (Integer.valueOf(content)).intValue() );
          else if (CurrentElement.equals("valid"))
               temp.setValid_period(content);
          else if (CurrentElement.equals("status"))     {
               temp.setStatus( (Integer.valueOf(content)).intValue() );
          else {}
     public void endElement(String uri, String name, String qName)     {
          System.err.println("DEBUG" + temp.toString()); /*debug*/
          if (name.equals("event"))     {
               try     {
                    /*debug*/ temp.setUserID(1);
                    /*debug*/ System.err.println("DEBUG: " + temp.toString());
                    sendSQL(temp, db_connection);
                    //temp = new Event();
               catch (SQLException e)     {
                    System.err.println(e);
               }//end catch
          }//end try
Where event is a public class Event     {
     //fields
     private int userID = 1; // = 1 only applies for testing
     private int eventID;
     private String short_description;
     private String long_description;
     private Date date_time = null;
     private int repeat_pattern;
     private String valid_period;
     private int status;     //1 for new, 0 for modification and -1 for delete
     SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
     //Constructors
     //every event requires the following: userID eventID and short_Description
     public Event(int uID, int eID, String shortDescrp)     {
          setUserID(uID);
          setEventID(eID);
          setShort_description(shortDescrp);
     public Event(int uid, int eid, String sd,
                              String ld, Date d_t, int r_p, String v_p, int s)     {
          setUserID(uid);
          setEventID(eid);
          setShort_description(sd);
          setLong_description(ld);
          setDate_Time(d_t);
          setRepeat_pattern(r_p);
          setValid_period(v_p);
          setStatus(s);
     //set
     public void setUserID (int x)                         { this.userID = x ;}
     public void setEventID (int x)                         { this.eventID = x ;}
     public void setShort_description (String x)          { this.short_description = x ;}
     public void setLong_description (String x)          { this.long_description = x ;}
     public void setDate_Time(Date x)                    { this.date_time = x ;}
     public void setRepeat_pattern (int x)               { this.repeat_pattern = x ;}
     public void setValid_period (String x)               { this.valid_period = x ;}
     public void setStatus (int x)                         { this.status = x; }
     //get
     public int           getUserID()                              { return this.userID;}
     public int           getEventID()                         { return this.eventID;}
     public String      getShort_description()               { return this.short_description;}
     public String      getLong_description()               { return this.long_description;}
     public Date        getDate_Time()                         { return this.date_time;}
     public int         getRepeat_pattern()                    { return this.repeat_pattern;}
     public String      getValid_period()                    { return this.valid_period;}
     public int           getStatus()                              { return this.status; }
     //Event to SQL statements;
     public String toSQL()     {
          StringBuffer sb = new StringBuffer();
          ///if ( status == 1)     {
               sb.append( "INSERT INTO events SET" );
               sb.append( " userID = " + userID + ", ");
               sb.append( "eventID = " + eventID + ", " );
               sb.append( "short_description = " + "\'" + short_description + "\'" + ", "); //String
               sb.append( "long_description = " + "\'" + long_description + "\'"  + ", "); //String
               sb.append( "date_time = " + "\'" + formatter.format(date_time) + "\'" + ", ");
               sb.append( "repeat_pattern = " + repeat_pattern + ", " );
               sb.append( "valid_period = " + "\'" + valid_period + "\'" ); //String
               sb.append( ";");
          //} else if ( status == 2)      {
          System.err.println(sb.toString());
          return sb.toString();
}     My question is: I have taken my SQL query generated by toSQL() method in events and it worked.
Here is the funny thing:
Everything is correct syntax wise: No complaints what soever
The mysql part works: Tested separately.
So I tend to think that the problem lies within the SAX parser. I have written SAX2 parsers on this machine before and they have worked too. I tried inserting println statements all over startElement endElement etc etc only to find out that the SAX parser did not call any of the methods that I overided!! Why is that so?
Can you guys spot where my SAX parser fails?

I see.
I try to correct this problem by removing super();
so right now my code looks like this:
     static Event temp = new Event(0, 0, "null", "null", new Date(), 0, "null", 0);
     static String CurrentElement = null;
     static File XMLpath;
     static Connection db_connection;
     static XMLReader xr;
     static DefaultHandler XMLSAXhandler; 
     //Constructor,      Build the SAX Parser
     public EventXMLParser(File path, Connection connection)     {
          try     {
               this.XMLpath = path;
               this.db_connection = connection;
               this.xr = XMLReaderFactory.createXMLReader();
               this.XMLSAXhandler  = new DefaultHandler(); //create a new own handler
               this.xr.setContentHandler(XMLSAXhandler);
               this.xr.setErrorHandler(XMLSAXhandler);
               //System.out.println("DEBUG: db_connection is " + db_connection.toString());
          catch (Exception e)     {
               System.out.println("Constructor Error!");
               e.printStackTrace();
     }This time, I created a new instance of default handler() which can be referenced by as the objects's XMLSAXhandler. However, that did not solve the problem, why does the problem still persist?
Right now, there is only one instance of a default handler created. So why does all my parsing event functions still get ignored?

Similar Messages

  • Why are all of our cords breaking, so we can not charge anything?

    Why are all of the cords so cheap, and breaking?

    I am pretty certain that Apple put something into iOS 6.1.4 to REJECT all 3rd-party power cords.  Ever since I updated to iOS 6.1.4, my most trusted cord (4 months old) has been saying, "You cannot charge the device with this cord".  BZZZT Apple strikes again !!
    Either that, or the new "Kill your battery as quickly as possible" software in iOS 6.1.4 has been draining power so rapidly, that my 3rd-party cord cannot keep up with the massive power-draw from iOS 6.1.4 !!  Don't upgrade !!

  • Why are all my events showing up twice?  Each time I enter a new event, it duplicates (same day, same time, same details)

    The events auto duplicate - on the computer I use to enter them and on others that are synched to it.  If I delete one of the identical entries, both disappear.  Any suggestions?  Driving me nuts!  (ok, it may not be a long drive....)
    Thanks!!

    I have sort of the exact same problem. Extremely far away from user friendly
    I have an second issue as well: When I hook off all-day it comes up with an 8 hour event!
    And then if I put in a late start hour it pushes end time to next day due to the 8 hour event suggestion.
    All in all this gives a lot of changes just to enter an event.
    Command N
    I learnt from your input to use this fuction. At least that comes up with a one hour event as default.

  • Why are all my songs now classified as 'Other' and not visible on my phone any more?

    Here's an idea of what's happened recently;
    Got a new a computer and set up my iTunes library no problem, had access to all the same music I had on my old PC.
    Just added a new album to my iTunes library, which also worked fine, but when I tried to sync it to my iPhone 5 I wasn't able to transfer anything to it.
    I used iTunes to back up my iPhone and do a full restore on the iPhone hoping that would fix the issue.
    Now my 35GBs of Music is classified as 'Other' storage, there's not enough room on the iPhone to transfer all my songs to it again and no way to delete the 'Other' storage to make space for it.
    I have tried unchecking 'Sync only checked songs and videos' and rechecking it. I have also tried unchecking and checking 'Sync Music'. Either way I go the iPhone still has 35GBs of Other storage I can't seem to remove.
    Any help or support?

    I ended up doing a Full Restore on my iPhone without restoring from a previous backup. I'm just curious what I have to do in the future to prevent this issue if I switch PC's again.

  • Why are all-day calendar events not appearing in the Notification Center?

    I've noticed that all-day Calendar events do not appear in the Notfication Center in iOS. This is a glaring omission and I'm not sure if it's related to a bug or is intentional but it should be fixed right away. Why in the world would you leave out an all-day event from the Notification Center? What if I had a wedding anniversary or some other important event to remember?

    IOS / is no out for a couple of weeks and Apple seems to be reluctant to fix this problem. As a business device it becomes rediculous to be not able to see my calender entries anymore in the notification center. Is Apple now leaving the business arena and focusing on toys ?

  • Why are all my movies and tv shows now on my ipad with the icloud icon?  How can i get rid of them?

    Why are all my movies and tv shows from my library now on my ipad with the icloud icon?  I have turned off all icloud related services. I have never used it.  On top of that, my ipad now gets stuck on step 5 of the sync - waiting for changes to be applied and never finishes.
    Help

    Hi, go in Settings, under Videos turn off "Show all videos"  this will remove the purchased videos to be displayed in the Video app.  The same can be done with the music.
    As for Step 5, connect you iPad and on the summary Tab, uncheck
    "Sync only checked songs and videos".  Then wait, it takes a while but this made it work for me after many restore attempts.
    good luck

  • The new event are created when i import photo in the top. Before they where put in the end. All my event are classified. Where i can set the event at the end ? Thank's.

    The new event are created when i import photo in the top.
    Before they where put in the end.
    All my event (around 600) are classified on the top the old and a the end the new.
    Where i can set the event at the end ?
    Thank's.

    View menu  ==> sort events
    LN

  • In iTunes under my device, under the apps tab, Why are all the options shaded out?  I cannot make any changes, select any apps or do anything with the apps.  I was able to load a few apps and sync but cannot sync anymore to my phone.

    In iTunes under my device, under the apps tab, Why are all the options shaded out?  I cannot make any changes, select any apps or do anything with the apps.  I was able to load a few apps and sync but cannot sync anymore to my phone.

    Hi,
    ( I search for iChat questions when I have finished in the iChat Forum)
    So the menu bar reads iChat, File,  Edit,  View, Buddies, Video, Window and Help
    There is no Buddy List open.
    There is no other window for iChat open.
    In the iChat Menu you only have access to Status.
    Is an item ticked in the list ?
    Is this a green (Available item) or  Red ( an Away one) ?
    Can you access the Accounts option ?  (Sitll in the iChat Menu)
    Is anything in here ticked ?
    In the Window menu any Logged in account should appear in the list  (Between the Next Chat and File Transfer items)
    It would be useful to know which version of iChat this is.
    If no account is ticked (iChat Menu > Accounts) or not showing in the Window Menu, plus you cannot determine the Status and you cannot access the Preferences then you need to access your Home Folder/Library/Preferences
    As the Library in the Home Holder is Invisible in Lion you will need the Finder's Go Menu > Go to Folder option  (you can use it in earlier OS versions if you want)
    Type in:-
    ~/Library/Preferences
    Find the file called com.apple.ichat.plist
    Drag it to the Trash and Restart iChat.
    This will lose all the settings in iChat that you have changed from Defaults but there is no way around this.
    9:23 PM      Saturday; August 27, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb( 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • How to view what are all programs maped with the event....

    I am new to this events concept - could you please say
    in SM64 we can give Event....
    <b>How to view what are all programs maped with the event..</b>
    Thanks in advance.

    Hi Sam,
    See these links:
    How-to trigger a process chain using ABAP?
    Re: scheduling process chain 3 specific times a day
    NOTE: If you want to trigger the process chain from R/3, there are many examples in this forum. However, since the search function is not working now, I suggest you look at OSS Note 135637. This will show you how to do it also.
    Hope this helps.
    concerning to sm64 ..
    Triggering events manually ...
    Events let you start background jobs when particular changes in the R/3 System take place. When an event occurs, the background processing system starts all jobs that were scheduled to wait for that event.
    example : JOB_OPEN to create a background job..
    When scheduling a background job, you can specify it to start "after event".
    If you do so, you'll have to create an event in SM62.
    If a job is scheduled after event event and you trigger the event with SM64, the job will start.
    Events can be raised by external systems in SAP by sending a command to a SAP application server. You can also raise event in any program using function mosule BP_EVENT_RAISE.
    Reward if helpful.
    Regards,
    Harini.S

  • HT3726 why are all of the templates in Spanish?

    Why are all the templates and text in Spanish on Pages

    It is Latin nonsense, placeholder text to show the layout. Click in a text box and start typing. Your text will replace it.
    Regards,
    Ian.

  • In ICal is there a way to see all of the text in all day events on the month view of the calendar.  Seems to wrap text only if there is a time on the event

    In ICal is there a way to see all of the text in all day events on the month view of the calendar?  Seems to wrap text only if there is a time on the event

    The paths won't agree on the two OSs so a simple XML import isn't likely to work.
    See Sync iPod/iPad/iPhone with two computers and, if needed, Make a split library portable. The techniques in the first link will work when moving the library between Windows and OS X as long as the library is "portable", but iTunes takes quite some time checking the database when the library is opened under a different OS.
    tt2

  • How can I move an event in my calendar to my "completed" calendar without changing all the events in the series?

    How can I move an event in my calendar to my "completed" calendar without changing all the events in the series?
    As Apple has yet to upgrade iCalendar so I can check off my events as I complete them (no, I do not want to use a task list/reminder list), I want to be able to move my events to my "completed" events calendar as I complete them. The issue is that most of my events are repeating events, and it changes the entire series. How do I change only the event I clicked on using my iPhone?
    Thanks

    If you change anything in a repeating calendar entry it will give you the option of disconnecting it from the series. So may any random change, choose to not change the series.

  • Why are photos again available on the fotostream even that I have deleted them?

    Hi,
    why are photos again available on the Fotostream, even that I have deleted them with using an iphone?

    Hi Ghallsa,
    I don't know why you believe that emails would be using 6go if you deleted them all.  I think you concluded this from the available space left and what you know is using space.  You have to understand that what is taking storage space is not only apps, music and emails.  There is also the iOS which is taking space as well as a lot of data cached on your devices that will usually be shown as 'Other' category if you are to look at your space usage from iTunes.
    If the total 'Other' space appears excessive, I suggest you should 'restore' your device (after a full recent backup); this sometimes helps to remove any data left behind.  But before this, try a look at Settings->General->Usage->Manage Storage.  This will list apps from the most space consuming to the less.  It could also help you to identify which apps may take to much of your precious space not only by apps size but also from the data the apps had stored.
    good luck,

  • HELP. ............Hi folks hope some one can help me please.Having a problem in Bridge I open my images in ACR,  as I open files in a folder and lets say they are labeled in yellow  they are all going back to  the camera raw default , in other words no ma

    HELP. ............Hi folks hope some one can help me please.Having a problem in Bridge I open my images in ACR,  as I open files in a folder and lets say they are labeled in yellow  they are all going back to  the camera raw default , in other words no matter what work I have done, inc cropping they  all go back to ,as they came out of camera. What on earth is happening? I am on PS CS6. I might point out everything was working normally up to  yesterday, when this first started.
    I recently changed computer to 64bit from 32bit, not sure if this causing  the problem or not. Any help would be appreciated.

    Robert,
    Would you be so kind to rephrase your question with concise, precise information and without any "let's say that" hypotheticals?  Sorry, I can't quite follow you.
    Also please give exact versions of Photoshop CS6 (13.what.what), of Bridge and of your OS.
    Thanks.
    BOILERPLATE TEXT:
    If you give complete and detailed information about your setup and the issue at hand, such as your platform (Mac or Win), exact versions of your OS, of Photoshop and of Bridge, machine specs, what troubleshooting steps you have taken so far, what error message(s) you receive, if having issues opening raw files also the exact camera make and model that generated them, etc., someone may be able to help you.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • I have 2 phones on my iTunes account, why are text messages showing on the second phone when sent from the first

    I have 2 phones on my iTunes account, why are text messages showing on the second phone when sent from the first phone?

    it's meant to work like that
    so if you receive a message on your iphone you also get it on your ipad or ipod touch
    to avoid it use separate appleID for each device
    or turn off imessage on 1 or both devices in their settings
    but that will not fix the issue that 2 devices using the same appleID will never be able to facetime eachother
    the appleID is a unique handle for 1 user only

Maybe you are looking for

  • Setting Payment terms in PO linking to base line date for payables.

    Hi can some help me by giving me simple  steps to create  the payment terms which will be captured in PO and payment is made with reference to baseline date. Example : 1. payment in 15 days from the date of GRN posting date. while doing MIRO, the bas

  • Db_keep_cache_size shows 0 when i keep object in KEEP buffer pool !

    Dear Frineds , I use Oracle 10g . Form the oracle 10g documentaiton, I get the following information regarding ASMM (Automatic Shared Memory Management) : The following pools are manually sized components and are not affected by Automatic Shared Memo

  • Manage multiple Skype Manager accounts

    I am already the administrator of a Skype manager account but i want to set up another Skype manager account for another company I control using my existing skype profile? is this possibile? If that is not clear, then what I want to achieve is to hav

  • Cannot use isqlplus! help!!

    Hello! I just installed the downloaded version of Oracle9i (version 2) onto an XP Home partition, and although everything else seems to be working so far, I cannot get on to use isqlplus, and I cannot figure out why! The infamous "this page cannot be

  • Custom alaw encoder does not handle media time

    Hi All, I'm trying to create a custom alaw rtp packetizer but not succeeding. I read all the rtp/alaw related forum topics and found a great help in implementing it but the time of the media is not handled with the current code. I created custom mult