Contest: Guess whats wrong with this code!

Can you guess whats wrong with this code snippet? Perhaps its too easy...
private void clearDefaultTableModel( DefaultTableModel dtm) {    
        int  rowCount  = dtm.getRowCount();
        for(int i =0;  i < rowCount; i++) {
            dtm.removeRow(i);  
    }- Karl XII

Can you guess whats wrong with this code snippet?
Perhaps its too easy...
private void clearDefaultTableModel(
DefaultTableModel dtm) {    
int  rowCount  = dtm.getRowCount();
for(int i =0;  i < rowCount; i++) {
dtm.removeRow(i);  
it should be
private void clearDefaultTableModel(DefaultTableModel dtm) {    
   int  rowCount  = dtm.getRowCount();
   for(int i =0;  i < rowCount; i++) {
     dtm.removeRow(0);  
}or another way
private void clearDefaultTableModel(DefaultTableModel dtm) {    
  while(dtm.getRowCount()>0){
     dtm.removeRow(0);  

Similar Messages

  • HELP PLEASE - WHATS WRONG WITH THIS CODE

    Hi. I get this message coming up when I try to compile the code,
    run:
    java.lang.NullPointerException
    at sumcalculator.SumNumbers.<init>(SumNumbers.java:34)
    at sumcalculator.SumNumbers.main(SumNumbers.java:93)
    Exception in thread "main"
    Java Result: 1
    BUILD SUCCESSFUL (total time: 2 seconds)
    I am not sure whats wrong with the code. Any assistance would be nice. The code is below.
    package sumcalculator;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SumNumbers extends JFrame implements FocusListener {
    JTextField value1;
    JTextField value2;
    JLabel equals;
    JTextField sum;
    JButton add;
    JButton minus;
    JButton divide;
    JButton multiply;
    JLabel operation;
    public SumNumbers() {
    SumNumbersLayout customLayout = new SumNumbersLayout();
    getContentPane().setFont(new Font("Helvetica", Font.PLAIN, 12));
    getContentPane().setLayout(customLayout);
    value1.addFocusListener(this);
    value2.addFocusListener(this);
    sum.setEditable(true);
    value1 = new JTextField("");
    getContentPane().add(value1);
    value2 = new JTextField("");
    getContentPane().add(value2);
    equals = new JLabel("label_1");
    getContentPane().add(equals);
    sum = new JTextField("");
    getContentPane().add(sum);
    add = new JButton("+");
    getContentPane().add(add);
    minus = new JButton("-");
    getContentPane().add(minus);
    divide = new JButton("/");
    getContentPane().add(divide);
    multiply = new JButton("*");
    getContentPane().add(multiply);
    operation = new JLabel();
    getContentPane().add(operation);
    setSize(getPreferredSize());
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    public void focusGained(FocusEvent event){
    try {
    float total = Float.parseFloat(value1.getText()) +
    Float.parseFloat(value2.getText());
    sum.setText("" + total);
    } catch (NumberFormatException nfe) {
    value1.setText("0");
    value2.setText("0");
    sum.setText("0");
    public void focusLost(FocusEvent event){
    focusGained(event);
    public static void main(String args[]) {
    SumNumbers window = new SumNumbers();
    window.setTitle("SumNumbers");
    window.pack();
    window.show();
    class SumNumbersLayout implements LayoutManager {
    public SumNumbersLayout() {
    public void addLayoutComponent(String name, Component comp) {
    public void removeLayoutComponent(Component comp) {
    public Dimension preferredLayoutSize(Container parent) {
    Dimension dim = new Dimension(0, 0);
    Insets insets = parent.getInsets();
    dim.width = 711 + insets.left + insets.right;
    dim.height = 240 + insets.top + insets.bottom;
    return dim;
    public Dimension minimumLayoutSize(Container parent) {
    Dimension dim = new Dimension(0, 0);
    return dim;
    public void layoutContainer(Container parent) {
    Insets insets = parent.getInsets();
    Component c;
    c = parent.getComponent(0);
    if (c.isVisible()) {c.setBounds(insets.left+24,insets.top+48,128,40);}
    c = parent.getComponent(1);
    if (c.isVisible()) {c.setBounds(insets.left+256,insets.top+48,128,40);}
    c = parent.getComponent(2);
    if (c.isVisible()) {c.setBounds(insets.left+408,insets.top+48,56,40);}
    c = parent.getComponent(3);
    if (c.isVisible()) {c.setBounds(insets.left+488,insets.top+48,152,40);}
    c = parent.getComponent(4);
    if (c.isVisible()) {c.setBounds(insets.left+128,insets.top+136,72,40);}
    c = parent.getComponent(5);
    if (c.isVisible()) {c.setBounds(insets.left+248,insets.top+136,72,40);}
    c = parent.getComponent(6);
    if (c.isVisible()) {c.setBounds(insets.left+368,insets.top+136,72,40);}
    c = parent.getComponent(7);
    if (c.isVisible()) {c.setBounds(insets.left+488,insets.top+136,72,40);}
    c = parent.getComponent(8);
    if (c.isVisible()) {c.setBounds(insets.left+176,insets.top+48,56,40);}
    }

    Thank you. How do i amend this? I have defined value1though.Yes, you did - but after the call to addFocusListener(...). It needs to be before it.
    BTW, you did the same thing with "value2.addFocusListener(this)" and "sum.setEditable(true)" on the next two lines. You're attempting to call a method on an object that doesn't exist yet (i.e., you haven't called new yet).

  • Fed up! dont know whats wrong with this code

    import java.io.*;
    import java.net.*;
    import java.awt.*;
    public class machine {
         private String machine_name;
         private String IP_address;
         public static void main(String[] args) throws IOException {
                   machine server = new machine();
                   server.machine_name = "SERVER1";
                   server.IP_address   = "192.168.0.1";
                   InputStreamReader reads_incoming = null;
                   // Reads incoming Bytes
                   PrintWriter sends_outgoing = null;
                   Socket ping_socket         = null;
                   try{
                        ping_socket = new Socket(server.machine_name , 7);
                        sends_outgoing = new PrintWriter(ping_socket.getOutputStream(),true);
                        reads_incoming = new InputStreamReader(ping_socket.getInputStream());
                   catch (UnknownHostException e){
                        //report error to sole text box
                   catch (IOException e)
                        //similar
                   /* Need a string to send some arbitrary bytes to SERVER1
                    * using IP_address instead , as this field in this implementation
                   while(true)
                        sends_outgoing.println(server.IP_address);
                        if(ping_socket.getInputStream() != null)
                             System.out.print("Server is up");
    }

    same... i am not very experienced, and try and uses this as training... but as new to java programming i could still mention about 5 things that might be wrong with this code... so a deeper explanation would be nice...
    while(true) { } for example seems like a nice way to make infinite loop that can suck your memory out of your computer pretty fast :-) newb

  • Whats Wrong with this code? URLReader

    Ok, so I have this URLReader.java program. It goes to a specific website, I put in a project ID. It pulls up a project. I can then "Scrape", "Extract Data from the URL and put them into variables. I then upload the variables into the DB.
    I've used this code over and over again and it works, but I seem to have a problem with the second part of the code.The error message that I get is:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
    Please note the URL is a fake one. I did not want to give the real URL. I have provided the String to read, which is actually HTML code. I thought it might be the "Researchers(s):" string that it does like, maybe a problem with "(s), but I dont know?
    First part of the code: This really gets a project ID from a collection and iterates throught the collection with each project ID.
    String projectId = "87023";
                java.net.URL projectDetails = new  java.net.URL("http://someSite.com/portfolio/ProjectDetails.asp?Source=Tracking&Key="+projectId);
                java.io.BufferedReader in =
                            new java.io.BufferedReader(new java.io.InputStreamReader(projectDetails.openStream()));
                String projDetailspage = new String("");
                String inputLine = "";
                while ((inputLine = in.readLine()) != null)
                    projDetailspage = projDetailspage.concat(inputLine.trim());
                System.out.println("project ID: "+ projectId);
    Second Part of the Code:
    String str = (projDetailspage.split("\\<[Bb]\\>Researcher(s)\\</[Bb]\\>")  //  look for: <b>Researcher(s):</b> , also the part of code I am having problems with.
                [1].split( "\\<td\\>")[1].split("\\</table>")[0].trim());   //put everything into a variable call str from the <td> to the </table> tags 
                System.out.println("String before replace all: "+ str);
    The HTML code to read and search through:<!-- researchers -->
        <tr>
              <td width="30%" align="right" valign="top">
                   <font size="-1">
                   <b>Researcher(s):</b>
                   </font>
              </td>
                  <td width="70%" align="left" valign="top">
                        <font size="-1">
                        Dr. Michael E. Welge, University of Illinois at Urbana-Champaign
                        </font>
                   </td>
                   </tr>
                            <tr>
                                  <td width="30%">
                                       <font size="-1">
                                       </font>
                                  </td>
                                <td width="70%" align="left" valign="top">
                                       <font size="-1">
                                       Dr. Albert J. Valocchi, University of Illinois at Urbana-Champaign
                                       </font>
                                  </td>
                            </tr>
                            <tr>
                                  <td width="30%">
                                       <font size="-1">
                                       </font>
                                  </td>
                                <td width="70%" align="left" valign="top">
                                       <font size="-1">
                                       Dr. Barbara Ann Bailey, University of Illinois at Urbana-Champaign
                                       </font>
                                  </td>
                            </tr>
                            <tr>
                                  <td width="30%">
                                       <font size="-1">
                                       </font>
                                  </td>
                                <td width="70%" align="left" valign="top">
                                       <font size="-1">
                                       Dr. David E. Goldberg, University of Illinois at Urbana-Champaign
                                       </font>
                                  </td>
                            </tr>
         <!-- students -->
        <tr>
              <td width="30%" align="right" valign="top">
                   <font size="-1">
                   <b>Student(s):</b>
                   </font>
              </td>
                   <td width="70%" align="left" valign="top">
                        <font size="-1">
                        None Found
                        </font>
                   </td>
              </tr>
              </table>
              </td>
         </tr>
         </table>
         </td>
    </tr>
    </table>

    camickr
    I ran your program and it works great. This is the output I get. This is for a project that had 4 researchers, that is not always the case.
    investigator1 = r. Michael E. Welge
    investigator2 = Dr. Albert J. Valocchi
    investigator3 = Dr. Barbara Ann Bailey
    investigator4 = Dr. David E. Goldberg
    for some reason I loose the D in Dr. for the first Investigator.
    also, I know I need to modify my code to find out how many researchers there are. I then place them into the correct variable.
    example
    researchers String that your code works on: None Found</font></td></tr><!-- students --><tr><td width="30%" align="right" valign="top"><font size="-1"><b>Student(s):</b></font></td><td width="70%" align="left" valign="top"><font size="-1">Dr. Terry Hogan, Pennsylvania State University</font></td></tr><tr><td width="30%"><font size="-1"></font></td><td width="70%" align="left" valign="top"><font size="-1">Dr. Chengyu Shen, Pennsylvania State University</font></td></tr><tr><td width="30%"><font size="-1"></font></td><td width="70%" align="left" valign="top"><font size="-1">Dr. Anne Pifer, Pennsylvania State University</font></td></tr>
    investigator1 = one Found|Student(s):|Dr. Terry Hogan  // should be None Found.
    investigator2 = Dr. Chengyu Shen
    investigator3 = Dr. Anne Pifer
    npe errorjava.lang.ArrayIndexOutOfBoundsException: 3
    The logic should be, when I scrape between tags, if it should be "None Found" then skip to the next project ID , also, each project may have as many as 0, 1, 2, 3, 4 researchers. but no more than 4
    So I thought of doing an:
    If( researchers == 2)
        investigator1 = investigator[x];
        investigator2 = investigator[x];
    }etc...
    Thanks again.
    if you need me to email you the code. my email addres is [email protected]
    I know I am not that talented of a programmer, but I am learning, and trying all the time. I want to do this the correct way, but I am not always sure which way that is. I usually try a class Diagram and go from there, but I have had some trouble with this one. If you need more of an explanation then email me.
    orozcom

  • Can understand whats wrong with this code.

    I'm sort new to Java programing, and I created this simple converter, but when I try to complie it, it gives me an exception error, could some one tell me how to correct this code.
    import java.text.*;
    import javax.swing.*;
    public class Converter
         private final static double EURO = .8295577, YEN = 115.614, CAD = 1.17781;
         public static void main (String[] args)
               String input =null;
               double US= 0.0;
               DecimalFormat twoPrecision = new DecimalFormat("0.00");
             input() = 0
              try{
                   US = Double.parseDouble (input);
                    System.out.print("US to Euro: ");
                    System.out.println(twoPrecision.format(US * EURO));
                  US = Double.parseDouble (input);
                    System.out.print("US to Yen: ");
                    System.out.println(twoPrecision.format(US * YEN));
                  US = Double.parseDouble (input);
                    System.out.print("US to Cad: ");
                    System.out.println(twoPrecision.format(US * CAD));
              catch(NumberFormatException e)
                   JOptionPane.showMessageDialog(null,
                                    "You must enter a number",
                                    "Input data error",
                                    JOptionPane.ERROR_MESSAGE);
    }

    Try this:
    import java.text.*;
    import javax.swing.*;
    import java.io.*;
    public class Converter
         private final static double EURO = .8295577, YEN = 115.614, CAD = 1.17781;
         public static void main (String[] args)
               double US= 0.0;
               DecimalFormat twoPrecision = new DecimalFormat("0.00");
               try{
                   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
             String input=br.readLine();
                   US = Double.parseDouble (input);
                    System.out.print("US to Euro: ");
                    System.out.println(twoPrecision.format(US * EURO));
                  US = Double.parseDouble (input);
                    System.out.print("US to Yen: ");
                    System.out.println(twoPrecision.format(US * YEN));
                  US = Double.parseDouble (input);
                    System.out.print("US to Cad: ");
                    System.out.println(twoPrecision.format(US * CAD));
              catch(Exception e)
                   JOptionPane.showMessageDialog(null,
                                    "You must enter a number",
                                    "Input data error",
                                    JOptionPane.ERROR_MESSAGE);
    }

  • Whats  wrong with this code?

    Hi Experts,
    I am getting the error as " the method get_data has no returning parameter.
    Can someone please help me with this.
    CLASS main DEFINITION.
      PUBLIC SECTION.
        METHODS add_data IMPORTING i_data TYPE i.
        METHODS get_data EXPORTING e_data TYPE char20.
      PRIVATE SECTION.
        DATA attribute TYPE char01.
    ENDCLASS.
          CLASS main IMPLEMENTATION
    CLASS main IMPLEMENTATION.
      METHOD add_data.
        ADD i_data TO attribute.
      ENDMETHOD.
      METHOD get_data.
        CONCATENATE 'Attribute value' attribute
                                   INTO e_data SEPARATED BY space.
      ENDMETHOD.
    ENDCLASS.
    DATA: object_reference TYPE REF TO main.
    end-of-selection.
      CREATE OBJECT object_reference.
      DATA:
      var TYPE char20.
      CALL METHOD object_reference->add_data( i_data = 3 ).
    var = object_reference->get_data( ).  --> errored here
      WRITE var.

    Hi Dan, if you want to use a RETURNING parameter when you call you method, you need to define the parameter as a RETURNING parameter in your class definition.
        METHODS get_data RETURNING VALUE(e_data) TYPE char20.
    You had defined it as an EXPORTING parameter, which means that when you call the method you would have need to use this syntax instead.
       object_reference->get_data( IMPORTING e_data = var ).
    Regards,
    Rich Heilman

  • Passing events - whats wrong with this code?

    hi,
    I'm trying to get components to behave in a frame like they would as though I had written
    frame.getContentPane().add(thecomponent);
    by processing events explicitly. I've written the code below as a test, and it does work, but the events do not seem to be passed to the component at the right level.
    For example, when the JTree is the component tried it does not expand nodes when you click on them.
    Or if you tree a JButton then it doesn't actually visibly "click"
    I'm still quite new with Swing so any help would be really appreciated - is this kind of thing even possible?
    thanks,
    asjf
    import javax.swing.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    public class EventTest extends Component
         Component notAttached;
         class SimpleMouseListener implements MouseListener
              String owner;
              Component passOnTo;
              SimpleMouseListener(String owner, Component passOnTo)
                   this.owner = owner;
                   this.passOnTo = passOnTo;
              public void mouseClicked(MouseEvent e){passOn(e);}
              public void mousePressed(MouseEvent e){passOn(e);}
              public void mouseReleased(MouseEvent e){passOn(e);}
              public void mouseEntered(MouseEvent e){passOn(e);}
              public void mouseExited(MouseEvent e){passOn(e);}
              public void passOn(MouseEvent e)
                   System.out.println(owner+" "+e);
                   if(passOnTo!=null)
                        passOnTo.dispatchEvent(
                             new MouseEvent(passOnTo,
                                                      e.getID(),
                                                      System.currentTimeMillis(),
                                                      e.getModifiers(),
                                                      e.getX(), // needs offsetting relative to parent
                                                      e.getY(), // needs offsetting relative to parent
                                                      e.getClickCount(),
                                                      e.isPopupTrigger()
         EventTest()
              super();
              notAttached = new JTree(); //JButton("Hello");
                   notAttached.setSize(100,100);
                   notAttached.setVisible(true);
                   notAttached.addMouseListener(new SimpleMouseListener("unattached component",null));
         public void paint(Graphics g){notAttached.paint(g);}
         static void main(String [] arg) throws Exception
              JFrame frame = new JFrame("Passing events test");
                   frame.setSize(640,480);
                   frame.setVisible(true);
                   EventTest et = new EventTest();
                   frame.getContentPane().add(et);
                   frame.addMouseListener(et.new SimpleMouseListener("Frame listener",et.notAttached));
    }

    Sorry
    It doesn't compile.
    I'm not sure how to create the 6 processes to each add part of sum and then update the total for the next processor to sum the next part up, and i don't know where it goes either.
    I think it would be something like:
    public void run()
    try
    //this add it up
    total= array + total;
    System.out.println("PROCESSOR"+thisnumber+" Your total is " + total);
    sleep();
    update(total)
    and then do the same code for another processor.
    I'm confused do I have to name each processor and put the name in :
    public void Processor1 ()
    please help I'm very confused
    }

  • Please tell me whats wrong with this code for sendRedirect

    /**AckController.java**/
    import java.io.IOException;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import java.sql.*;
    import java.util.*;
    * @version      1.0
    * @author
    public class AckController extends HttpServlet {
         * @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
         public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
              System.out.println("in AckController.doGet():action: "+req.getParameter("action"));
              String viewName = "";
              viewName = "/TransportersLogin/jsp/dealerAck/DealerAddAck.jsp";
              req.setAttribute("temp","temp");
              System.out.println("1..in AckController.doGet():viewName: "+viewName);     
              resp.sendRedirect(viewName);
         * @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
         public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
              doGet(req,resp);
    /*********end of servlet**********/
    /****DealerAddAck.jsp****/
    <%@ page session="true" language="java" %>
    <%@ page import="javax.servlet.*,javax.servlet.http.*,java.net.*"%>
    <%
    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
    response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
    response.setHeader("Pragma","no-cache"); //HTTP 1.0
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    <link rel="stylesheet" href="/TransportersLogin/theme/stylesecure.css">
    <%
         out.println("in jsp");
         out.println("in jsp: temp value: "+(String)request.getAttribute("temp"));
    %>
    <script>
    function consolidate()
         alert("wait");
         //document.forms[0].action = "DealerConfirmAck.html";
         //document.forms[0].submit();
    </script>
    </head>
    <body>
    <form name="frmaddclaim">
      <table border="0" cellpadding="3" cellspacing="1" width="100%">
      </table>
      <table width="100%" border="0" cellspacing="1" cellpadding="3">
        <tr>
          <td class="TDHeader" height="18" colspan="2">Add Acknowledgement Receipt</td>
        </tr>
        <tr>
          <td class="TDcolorgreybold" height="18" align="left">
               Available Invoices
          </td>
        </tr>
      </table>
      <table width="100%" border="0" height="26" cellpadding="3" cellspacing="0">
        <tr>
          <td class="tdheader" colspan="2" height="22" align="right">
          <input type="button" value="Add Receipt" name="B3" onClick="javascript:consolidate();"></td>
        </tr>
      </table>
      <table width="100%" border="0" height="26" cellpadding="3" cellspacing="0" align="left">
        <tr>
          <td class="labeltextRed" height="18" align="left">Select an Invoice from the
          list and click "Add Receipt". </td>
        </tr>
      </table>
    </form>
    </body>
    </html>I am trying to set an attribute in the request object (attribute name is temp). But in the jsp it is not getting the value of the attribute. The request is not getting transferred. Please let me know what correction is needed.
    I have used RequestDispatcher as well but in that case the control doesnt go the jsp when i used sendRedirect the control goes only if there isnt any request.getattribute in the JSP page.
    Thanks
    Nikesh

    You can;t transfer the request object using response.sendRedirect;
    Use RequestDispatcher to transfer the request object into another page.
    For Example:
    RequestDispatcher dispatcher  = getServletContext().getRequestDispatcher(viewName);
                dispatcher.include(req, resp);

  • Whats wrong with this code? Error 1180.

    I keep getting the error 1180:Call to a possible undefined method getURL
    var jscommand:String = "window.open('www.adobe.com','win','height=1024,width=768,toolbar=no,scrollbars=yes');"; getURL("javascript:" + jscommand + " void(0);");
    Any help would be appreciated.
    Thanks guys.

    Got it.
    Thanks!

  • What the he** is wrong with this code?

    Hi,
    I have 2 tables. Primary table "resease" and secondary table (containing the foreign key) "kunden".
    Selecting a release (dropdownlist), will show you the corresponding entry of kunden (datatable).
    I added buttons to the datatable for deleting certain rows. This all works fine so far.
    But as you are going to delte the last entry of table kunden, I want to delte the corresponding entry of the table release as well. And by trying to do so, I get an exception telling in line "dataTable1Model.commit();"
    "java.sql.SQLException: Lock time out; try later."
    The exception disappears by deleting the inner try-catch block.
    So what is wrong with this code?
    Thank,
    Mark.
    PS: If you need the database-schema or anything else, let me know....
    public String delete_action() {
            try {
             //returns -1, so I can't use it     
                int rowCount = dataTable1Model.getRowCount();          
             //get affected row     
                com.sun.jsfcl.data.DataCache.Row row =
                dataTable1Model.getDataCache().get(dataTable1Model.getRowIndex());
                row.setDeleted(true);
                try {
                    //New RowSet for getting FK of affected line
                    JdbcRowSetXImpl pkRowSet = new JdbcRowSetXImpl();
                    pkRowSet.setDataSourceName("java:comp/env/jdbc/AVT");
                    pkRowSet.setCommand("SELECT fk_idrelease FROM kunden " +
                    "where fk_idrelease = ?");
                    //Convert Row into string
                    String myRow = row.toString();
                    //Getting the index of the first "=" (it's before the FK)
                    int index = myRow.indexOf("=")+1;
                    //Getting the number (FK) out of the string an casting it to int
                    int fk = Integer.parseInt(myRow.substring(index,(index+1)));
                    //Saving the FK in SessionBean1, so I can use it a parameter of
              //the setObject(int, Object)-method
                    getSessionBean1().setFk(fk);
                    //this will give me a RowSet of all lines containing the FK of
              //the affected row
              pkRowSet.setObject(1, getSessionBean1().getFk());
                    pkRowSet.execute();
                    pkRowSet.last();
                    int numRow = pkRowSet.getRow();
              //If the numRow (numbers of rows) is 1, go to cascade_delte
              //and delte the entry with primary key as well
                    if (numRow == 1) {
                        cascade_delete(); //not implemented yet
                }catch (Exception ex) {
                    error("Error counting affected rows: " + ex);
                dataTable1Model.commit();
                dataTable1Model.execute();
                info("Deleting row OK!");
            }catch (Exception e) {
                log("Page 1: Row delete exception: ", e);
                error("Error during deleting: " + e);
            } // end try catch
          return null;
        }

    just a guess - perhaps call pkRowSet.close() at the end of your try/catch?
    v

  • What is wrong with this code? on(release) gotoAndPlay("2")'{'

    Please could someone tell me what is wrong with this code - on(release)
    gotoAndPlay("2")'{'
    this is the error that comes up and i have tried changing it but it is not working
    **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 2: '{' expected
         gotoAndPlay("2")'{'
    Total ActionScript Errors: 1 Reported Errors: 1
    Thanks

    If you have a frame labelled "2" then it should be:
    on (release) {
        this._parent.gotoAndPlay("2");
    or other wise just the following to go to frame 2:
    on (release) {
         this._parent.gotoAndPlay(2);
    You just had a missing curly bracket...

  • I can't figure out what's wrong with this code

    First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
    One two buckle your shoe
    Three four shut the door
    Five six pick up sticks
    Seven eight lay them straight
    Nine ten this is the end.
    The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
    public class PoemSeventeen
    public static void main(String[] args)
    EasyReader console = new EasyReader();
    System.out.println("Enter a number for the poem (0 to quit): ");
    int n = console.readInt();
    if (n = 1) || (n = 2)
    System.out.println("One, two, buckle your shoe");
    else if (n = 3) || (n = 4)
    System.out.println("Three, four, shut the door");
    else if (n = 5) || (n = 6)
    System.out.println("Five, six, pick up sticks");
    else if (n = 7) || (n = 8)
    System.out.println("Seven, eight, lay them straight");
    else if (n = 9) || (n = 10)
    System.out.println("Nine, ten, this is the end");
    else if (n = 0)
    System.out.println("You may exit now");
    else
    System.out.println("Put in a number between 0 and 10");
    I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
    The EasyReader class code:
    // package com.skylit.io;
    import java.io.*;
    * @author Gary Litvin
    * @version 1.2, 5/30/02
    * Written as part of
    * <i>Java Methods: An Introduction to Object-Oriented Programming</i>
    * (Skylight Publishing 2001, ISBN 0-9654853-7-4)
    * and
    * <i>Java Methods AB: Data Structures</i>
    * (Skylight Publishing 2003, ISBN 0-9654853-1-5)
    * EasyReader provides simple methods for reading the console and
    * for opening and reading text files. All exceptions are handled
    * inside the class and are hidden from the user.
    * <xmp>
    * Example:
    * =======
    * EasyReader console = new EasyReader();
    * System.out.print("Enter input file name: ");
    * String fileName = console.readLine();
    * EasyReader inFile = new EasyReader(fileName);
    * if (inFile.bad())
    * System.err.println("Can't open " + fileName);
    * System.exit(1);
    * String firstLine = inFile.readLine();
    * if (!inFile.eof()) // or: if (firstLine != null)
    * System.out.println("The first line is : " + firstLine);
    * System.out.print("Enter the maximum number of integers to read: ");
    * int maxCount = console.readInt();
    * int k, count = 0;
    * while (count < maxCount && !inFile.eof())
    * k = inFile.readInt();
    * if (!inFile.eof())
    * // process or store this number
    * count++;
    * inFile.close(); // optional
    * System.out.println(count + " numbers read");
    * </xmp>
    public class EasyReader
    protected String myFileName;
    protected BufferedReader myInFile;
    protected int myErrorFlags = 0;
    protected static final int OPENERROR = 0x0001;
    protected static final int CLOSEERROR = 0x0002;
    protected static final int READERROR = 0x0004;
    protected static final int EOF = 0x0100;
    * Constructor. Prepares console (System.in) for reading
    public EasyReader()
    myFileName = null;
    myErrorFlags = 0;
    myInFile = new BufferedReader(
    new InputStreamReader(System.in), 128);
    * Constructor. opens a file for reading
    * @param fileName the name or pathname of the file
    public EasyReader(String fileName)
    myFileName = fileName;
    myErrorFlags = 0;
    try
    myInFile = new BufferedReader(new FileReader(fileName), 1024);
    catch (FileNotFoundException e)
    myErrorFlags |= OPENERROR;
    myFileName = null;
    * Closes the file
    public void close()
    if (myFileName == null)
    return;
    try
    myInFile.close();
    catch (IOException e)
    System.err.println("Error closing " + myFileName + "\n");
    myErrorFlags |= CLOSEERROR;
    * Checks the status of the file
    * @return true if en error occurred opening or reading the file,
    * false otherwise
    public boolean bad()
    return myErrorFlags != 0;
    * Checks the EOF status of the file
    * @return true if EOF was encountered in the previous read
    * operation, false otherwise
    public boolean eof()
    return (myErrorFlags & EOF) != 0;
    private boolean ready() throws IOException
    return myFileName == null || myInFile.ready();
    * Reads the next character from a file (any character including
    * a space or a newline character).
    * @return character read or <code>null</code> character
    * (Unicode 0) if trying to read beyond the EOF
    public char readChar()
    char ch = '\u0000';
    try
    if (ready())
    ch = (char)myInFile.read();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (ch == '\u0000')
    myErrorFlags |= EOF;
    return ch;
    * Reads from the current position in the file up to and including
    * the next newline character. The newline character is thrown away
    * @return the read string (excluding the newline character) or
    * null if trying to read beyond the EOF
    public String readLine()
    String s = null;
    try
    s = myInFile.readLine();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (s == null)
    myErrorFlags |= EOF;
    return s;
    * Skips whitespace and reads the next word (a string of consecutive
    * non-whitespace characters (up to but excluding the next space,
    * newline, etc.)
    * @return the read string or null if trying to read beyond the EOF
    public String readWord()
    StringBuffer buffer = new StringBuffer(128);
    char ch = ' ';
    int count = 0;
    String s = null;
    try
    while (ready() && Character.isWhitespace(ch))
    ch = (char)myInFile.read();
    while (ready() && !Character.isWhitespace(ch))
    count++;
    buffer.append(ch);
    myInFile.mark(1);
    ch = (char)myInFile.read();
    if (count > 0)
    myInFile.reset();
    s = buffer.toString();
    else
    myErrorFlags |= EOF;
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    return s;
    * Reads the next integer (without validating its format)
    * @return the integer read or 0 if trying to read beyond the EOF
    public int readInt()
    String s = readWord();
    if (s != null)
    return Integer.parseInt(s);
    else
    return 0;
    * Reads the next double (without validating its format)
    * @return the number read or 0 if trying to read beyond the EOF
    public double readDouble()
    String s = readWord();
    if (s != null)
    return Double.parseDouble(s);
    // in Java 1, use: return Double.valueOf(s).doubleValue();
    else
    return 0.0;
    Can anybody please tell me what's wrong with this code? Thanks

    String[] message = {
        "One, two, buckle your shoe",
        "One, two, buckle your shoe",
        "Three, four, shut the door",
        "Three, four, shut the door",
        "Five, six, pick up sticks",
        "Five, six, pick up sticks",
        "Seven, eight, lay them straight",
        "Seven, eight, lay them straight",
        "Nine, ten, this is the end",
        "Nine, ten, this is the end"
    if(n>0)
        System.out.println(message[n]);
    else
        System.exit(0);

  • Whath is wrong with this code???

    Whath is wrong with this code:
    import java.sql.*;
    class DataBaseConnexion
    Connection connexion;
    String url;
    DataBaseConnexion()
    {// 1-charger le driver JDBC-ODBC
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("chargement du driver r�ussi");
    catch(ClassNotFoundException exc) {
    System.out.println("Erreur de chargement du pilote !");
    }// d�finir le pseudo URL pour joindre la BD
    url = "jdbc:odbc:cdi";//2- se connecter � la base de donn�es
    try {
    connexion = DriverManager.getConnection(url, "user_name", "pass_word");
    System.out.println("connexion r�ussie");
    catch(SQLException exc){
    System.out.println("Erreur 1 ! - " + exc.toString());
    public static void main(String Arg[])
    DataBaseConnexion db = new DataBaseConnexion();
    }//this errors occure
    File "C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java" Line 40: Syntax Error
    ---------------- JDK Release Build ------------------
    Compiling C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java
    C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java:40: 'class' or 'interface' expected
    public static void main(String Arg[])
    ^
    C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java:45: 'class' or 'interface' expected
    ^
    C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java:47: 'class' or 'interface' expected
    ^
    3 errors
    Finished

    I think you should remove the last closing curly brackets two lines above the main method.
    Regards

  • Whats wrong with this query.can anyone help me......

    select CASE WHEN TO_NUMBER(SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'DDMMYYYY HH24:MM:SS'),13,2))>0 AND TO_NUMBER(SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'YYYYMMDD HH24:MM:SS'),13,2)) <14
    THEN TO_DATE(CONCAT(SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'YYYYMMDD HH24:MM:SS'),13,2)||'00',SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'YYYYMMDD HH24:MI:SS'),16)||'00'),'DD-MM-YYYY HH24:MI:SS') end
    from table;
    i have written this query.whats wrong with this query..........
    the error is "literal does not match format string"
    Reegards soumen

    Why does your date_format loose, ununify and not fix ?
    And what is your exact requirement?
    >>
    CASE WHEN
    TO_NUMBER(SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'DDMMYYYY HH24:MM:SS'),13,2))>0
    AND TO_NUMBER(SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'YYYYMMDD HH24:MM:SS'),13,2)) <14
    <<
    This is
    CASE WHEN TO_CHAR(START_TIME_TIMESTAMP,'MM') between '01' and '13'
    >>
    THEN TO_DATE(CONCAT(SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'YYYYMMDD HH24:MM:SS'),13,2)
    ||'00',
    SUBSTR(TO_CHAR(START_TIME_TIMESTAMP,'YYYYMMDD HH24:MI:SS'),16)||'00'),
    'DD-MM-YYYY HH24:MI:SS')
    <<
    This is
    TO_DATE(
    TO_CHAR(START_TIME_TIMESTAMP,'MM"00"SS"00"),
    'DD-MM-YYYY HH24:MI:SS')
    Obviously, format is not matching !
    SQL> select to_char(sysdate,'MM"00"SS"00') from dual;
    TO_CHAR(
    06004900
    SQL> select to_date('06004900','DD-MM-YYYY HH24:MI:SS') from dual;
    select to_date('06004900','DD-MM-YYYY HH24:MI:SS') from dual
    ERROR at line 1:
    ORA-01861: literal does not match format string

  • What wrong with this?

    I have a video that has sound, I brought it into afteraffects, made a composition and made some changes. I exported the composition (rendered it) for quick time to edit in photoshop - the video is about 7 minutes.
    Playing the video there is no sound....why?
    Bringing the video into photoshop for editing with content aware fill creates 500+ frames......is that normal?
    also whats the easiest way to move between aftereffects and photoshop in terms of editing frames? can I make changes in photoshop and watch it update in after effects?

    What wrong with this?
    Everything! Sorry, it's simply the most ill-conceived workflow I could imagine.
    Playing the video there is no sound....why?
    http://forums.adobe.com/thread/426347?tstart=0
    Bringing the video into photoshop for editing with content aware fill creates 500+ frames......is that normal?
    Yes. All video editing in PS is limited to 500 or 1000 frames, repsectively. There is no way to extend that range. Read the PS help!
    also whats the easiest way to move between aftereffects and photoshop in terms of editing frames?
    You don't. What you have in mind won't work, anyways. Content Aware Fill only works per frame and has no temporal stabilization, so each frame will have a different pattern and the resulting animation would flicker and wobble.
    can I make changes in photoshop and watch it update in after effects?
    That's what use File --> Reload Footage for or simply close and reopen the project.
    Mylenium

Maybe you are looking for