Help with these Exceptions!

Hello All,
when the code below is run and I select a table name that starts with the number 0 I get a Eception, which is fine but when I click back into the combobox where I have the Table name that sarts with the number 0,
it Thows that Exception again. How can I get my code to only thow that exception once?
Someone suggested to use the getId() for the Action event will do this. I have tried to find out how to use this but was unsucessfull. Please could someone help me?
Thanks
Dave
import javax.swing.*;
import javax.swing.table.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class ComboBoxTable{
static Connection conn2;
   static DatabaseMetaData DMD;
   static JComboBox group = new JComboBox();
   static JComboBox groupList = new JComboBox();
  public static void main(String[] args) {
try  {
          // Load the database driver
        Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ) ;
        conn2 = DriverManager.getConnection( "jdbc:odbc:myProject") ;
        DMD=conn2 .getMetaData();
        ResultSet rs=DMD.getTables(null,null,null,new String[]{"TABLE"});
        while(rs.next()) {
          group.addItem((String)rs.getString(3));
        rs.close() ;
     } catch (SQLException se ) {
        System.out.println( "SQL Exception: " + se ) ;
     } catch (Exception e ) {
        System.out.println( e ) ;
     group.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e)  {
          String tbl = (String)group.getSelectedItem();
          try {
                Statement st=conn2.createStatement();
             st.execute("SELECT * FROM "+tbl+" WHERE 1=0");
             ResultSet rs=st.getResultSet();
             ResultSetMetaData md=rs.getMetaData();
             groupList.removeAllItems();
             for (int i=1;i<=md.getColumnCount();i++) {
               groupList.addItem(md.getColumnName(i));
             st.close() ;
          } catch (SQLException se ) {
             System.out.println( "SQL Exception: " + se ) ;
          } catch (Exception ex ) {
             System.out.println( ex ) ;
int j=10;
      String[][] data = new String[j][2];
      for (int k=0; k<j; k++){
         String[] row = {"",""};
         data[k] = row;
    String[] colNames = {"Column A", "Column B"};
    JTextField jtf = new JTextField();
    JTable tbl = new JTable(data, colNames);
// Create the combo box editor
    DefaultCellEditor editor = new DefaultCellEditor(groupList);
// ADDED IN MY ATTEMPT TO HAVE TO COLUMNS WITH COMBOBOXES
    DefaultCellEditor editor2 = new DefaultCellEditor(group);
// Assign the editor to the second column
    TableColumnModel tcm = tbl.getColumnModel();
    tcm.getColumn(0).setCellEditor(editor2);
// ADDED
    tcm.getColumn(1).setCellEditor(editor);
// Set column widths
    tcm.getColumn(0).setPreferredWidth(200);
    tcm.getColumn(1).setPreferredWidth(100);
// Set row heighht
    tbl.setRowHeight(20);
    tbl.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    tbl.setPreferredScrollableViewportSize(tbl.getPreferredSize());
     JFrame f = new JFrame("ComboBoxDemo");
    f.getContentPane().add(new JScrollPane(tbl), "Center");
    f.pack();
    f.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent evt) {
         System.exit(0);
    f.setVisible(true);
}

If you can predict an exception with such certainty, you should put some sanity checking in your code to prevent the the exception from ever occurring.

Similar Messages

  • Sign on problems within Elements 10; plus cannot backup writing files error with file catalog.pse10db.  No indication what the problem is.  How do I get adobe help with these problems?

    Sign on problems within Elements 10; plus cannot backup, writing files error with file catalog.pse10db.  No indication what the problem is.  How do I get adobe help with these problems?

    Sign on problems within Elements 10; plus cannot backup, writing files error with file catalog.pse10db.  No indication what the problem is.  How do I get adobe help with these problems?

  • I need help with these two crash IDs nsStyleContext::FindChildWithRules(nsIAtom const*, nsRuleNode*) and DFusionWebPlugin@0x86b5

    I need help with these two crashes...
    PL_DHashTableOperate | GCGraphBuilder::NoteRoot(unsigned int, void*, nsCycleCollectionParticipant*)
    DFusionWebPlugin@0x86b5
    The first one happened a couple of days ago, a few times and not on any specific website.
    The second one only happens on the site below.

    The second one indicates a problem with the DFusionWebPlugin that shows in your More system details list.
    # D'Fusion Web Plug-In for Safari 64 bits (3.00.13774.0)
    # D'Fusion Web Plug-In (3.00.13774.0)
    What you posted are crash signatures.<br />
    It might help if you post the actual crash IDs (bp-xxxxxxxx-xxxxxxxxx-xxxx-xxxxxxxxxxxx).<br />
    You can find the IDs of the submitted crash reports on the <i>about:crashes</i> page.
    See http://kb.mozillazine.org/Breakpad (Mozilla Crash Reporter)

  • Help with these queries

    Hi all,
    I need a help with these queries, because is happening a strange problem when I try to execute it.
    This first query is executed faster than the other one, around 30 minutes faster.
    The queries are the same, but there is a single difference, I switch the hard code value '5.93218%' in a like condition by a variable P_COD_RAIZ || '%', because it can't be hard code.
    SELECT max(oh.ohipp) as mesano_ultfatura
    INTO V_MESANO_FATURA
    FROM sysadm.orderhdr_all@dl_bsc oh,
    customer_all@dl_bsc ca
    WHERE ca.custcode like '5.93218%'
    and ca.customer_id = oh.customer_id
    and oh.ohipp = (select max(yy.ohipp)
    from orderhdr_all@dl_bsc yy
    where yy.customer_id = oh.customer_id
    and oh.ohinvtype = 5);
    SELECT max(oh.ohipp) as mesano_ultfatura
    FROM sysadm.orderhdr_all@dl_bsc oh,
    customer_all@dl_bsc ca
    WHERE ca.custcode like P_COD_RAIZ || '%'
    and ca.customer_id = oh.customer_id
    and oh.ohipp = (select max(yy.ohipp)
    from orderhdr_all@dl_bsc yy
    where yy.customer_id = oh.customer_id
    and oh.ohinvtype = 5);
    What I want to know is, why the execution time of the second query is greater than the first, if the only difference between it is a variable instead of hard code?
    Thanks,
    Murilo.

    I assume column custcode is also varchar2. Then it looks like a problem with bind values and not evenly distributed data.
    When you first run the query with the parameter = '5%' you may get many values and another execution plan as with '5.93218%' on a second run. However the execution plan is saved between the first and second run and not adopted to the new values.
    There are ways out of this "bind" problem. But all have to do with providing us a good execution plan first.
    However you can start by yourself with forcing the use of the index on the column custcode.

  • Can you help me with these exceptions??

    Hi guys,
    from sunday i try to eliminate these exceptions from my jsf application and i've lost any confidence in my possibility to realize it.....
    It's surely a simple problem but i'm a newbie of jsf and java.
    These are the exadel msg
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: #{MyBean.retrieveblob}: javax.faces.el.EvaluationException: java.lang.NullPointerException
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)
         org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
    root cause
    javax.faces.FacesException: #{MyBean.retrieveblob}: javax.faces.el.EvaluationException: java.lang.NullPointerException
         com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
         javax.faces.component.UICommand.broadcast(UICommand.java:312)
         javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
         javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
         com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
         org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
    ant these are the files
    MyBean.java
    package giu;
    import org.apache.myfaces.custom.fileupload.UploadedFile;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.sql.Blob;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.StringTokenizer;
    import java.util.Vector;
    public class MyBean {
         private UploadedFile myFile;
         private String geneid=null;
        private int row=0;
        private int numberOfNumericColumns=0;
        private int col=0;
        String[]intest=null;
        private ArrayList rows = new ArrayList();
        Head h;
        byte middlerow=' ';
        byte endrow=';';
        byte[] data=null;
        Vector temp=new Vector(100000);
        String g=null;
        Riga r;
        Double val[];
        private String[] arraylinee;
        public boolean insRighe(Riga nuovo){
               return rows.add(nuovo);
        public List stampaRows(){
             return rows;}
        public Head stampaHead(){
             return h;}
        public byte[] getdata(){
             return data;
        public UploadedFile getMyFile() {
            return myFile;
        public void setMyFile(UploadedFile myFile) {
            this.myFile = myFile;
        public int getcol(){
             return col;
        public void setcol(int col){
             this.col=col;
        public int getrow(){
             return row;
        public void setrow(int row){
             this.row=row;
        public String[] getarraylinee(){
             return arraylinee;
        public void setarraylinee(String[] arraylinee){
             this.arraylinee=arraylinee;
    public String retrieveblob(){
              Database2 db = new Database2("nomeDB","root","shevagol");     
              try
              Connection dbo=db.getConnection();
              System.out.println("eccezione buona2");
                   System.out.println("eccezione buona2,5");
                   Statement st = dbo.createStatement();
                   System.out.println("eccezione buona3");
                   ResultSet rs;
                   rs = st.executeQuery("SELECT Data FROM tbl WHERE Nome='16'");
                   rs.first();
                   Blob blob = rs.getBlob("Data");
                   byte[] read = blob.getBytes(1, (int) blob.length());
                   st.close();
                   String lettura=new String(read);
                   String[] arraylinee=lettura.split(";");
                   /*for (int i = 0; i < arraylinee.length; i++) {
                     System.out.println(arraylinee);
              catch(SQLException e)
                   System.out.println("Si � verificato il seguente errore: " + e.getMessage());
                   e.printStackTrace();
              return "retrOk";
    This is my result.jsp page
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ page import="giu.MyBean" %>
    <%-- Instantiate class --%>
    <jsp:useBean id="myBean" class="giu.MyBean" scope="request"/>
    <html>
         <head>
              <title></title>
         </head>
         <body>
              <f:view>
                   <c:forEach items="${myBean.arraylinee}" var="linea" >
    <tr>
    <td>
    <c:out value="${linea}" />
    </td>
    </tr>
    </c:forEach>
              </f:view>
         </body>     
    </html>
    and these are web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
         <context-param>
              <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
              <param-value>client</param-value>
         </context-param>
         <filter>
              <filter-name>ExtensionsFilter</filter-name>
              <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
              <init-param>
                   <param-name>uploadMaxFileSize</param-name>
                   <param-value>100m</param-value>
              </init-param>
              <init-param>
                   <param-name>uploadThresholdSize</param-name>
                   <param-value>100k</param-value>
              </init-param>
         </filter>
         <filter-mapping>
              <filter-name>ExtensionsFilter</filter-name>
              <servlet-name>FacesServlet</servlet-name>
         </filter-mapping>
         <servlet>
              <servlet-name>FacesServlet</servlet-name>
              <servlet-class>
              javax.faces.webapp.FacesServlet</servlet-class>
              <load-on-startup>1</load-on-startup>
         </servlet>
         <servlet-mapping>
              <servlet-name>FacesServlet</servlet-name>
              <url-pattern>/faces/*</url-pattern>
         </servlet-mapping>
         <servlet-mapping>
              <servlet-name>FacesServlet</servlet-name>
              <url-pattern>*.faces</url-pattern>
         </servlet-mapping>
         <welcome-file-list>
              <welcome-file>index.jsp</welcome-file>
         </welcome-file-list>
    </web-app>
    and faces-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
                                  "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
    <managed-bean>
      <managed-bean-name>MyBean</managed-bean-name>
      <managed-bean-class>giu.MyBean</managed-bean-class>
      <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
      <from-view-id>/pages/MyForm.jsp</from-view-id>
      <navigation-case>
       <from-outcome>success</from-outcome>
       <to-view-id>/pages/MyResult.jsp</to-view-id>
      </navigation-case>
    </navigation-rule>
    <navigation-rule>
      <from-view-id>/pages/Login.jsp</from-view-id>
      <navigation-case>
       <from-outcome>Ok</from-outcome>
       <to-view-id>/pages/Menu.jsp</to-view-id>
      </navigation-case>
    </navigation-rule>
    <navigation-rule>
      <from-view-id>/pages/Menu.jsp</from-view-id>
      <navigation-case>
       <from-outcome>upload</from-outcome>
       <to-view-id>/pages/MyForm.jsp</to-view-id>
      </navigation-case>
      <navigation-case>
       <from-outcome>admin</from-outcome>
       <to-view-id>/pages/UserForm.jsp</to-view-id>
      </navigation-case>
      <navigation-case>
       <from-outcome>view</from-outcome>
       <to-view-id>/pages/ViewForm.jsp</to-view-id>
      </navigation-case>
      <navigation-case>
       <from-outcome>register</from-outcome>
       <to-view-id>/pages/Register.jsp</to-view-id>
      </navigation-case>
    </navigation-rule>
    <navigation-rule>
      <from-view-id>/pages/ViewForm.jsp</from-view-id>
      <navigation-case>
       <from-outcome>Result</from-outcome>
       <to-view-id>/pages/Result.jsp</to-view-id>
      </navigation-case>
    </navigation-rule>
    </faces-config>I hope someone can helps me...............
    P.S.
    Can someone says me a good program to debug my applications...?
    I try with exadel but i find it bit intuitive....

    I don't know JSF, but it appears you haven't included part of your application - the one causing the error with the line: #{MyBean.retrieveblob}
    I would assume the error is that you instantiate the bean with the name "myBean" (<jsp:useBean id="myBean" class="giu.MyBean" scope="request"/>) then refer to it as "MyBean". Java is case sensitive.

  • I need help with these adobe illustrator questions?

    Please help with the following questions. Thanks!!
    The keyboard short for selecting the direct selection tool is?
    The rectangle that shows the outermost dimensions of any box is called the?
    A floating panel can be placed on the panel dock by?
    The selection tool is displayed as a black arrow and is used to select, resize, or move an entire item.(true or false)
    One way to deselect an object is to click somewhere else on the document (true or false)
    A stroke is on the inside of a shape or object (true or false)
    The more text framed you use, the better your document. (true or false)
    The rectangle frame has a non printing X on it (true or false)
    To print preview a document, click on the Save icon on the standard toolbar. (true or false)

    I'm not sure if it's a good idea to go the route you go now.
    You are asking for assistance and – as I understand it – you are just trying to pass a class right now, but you don't know the answers to a lot of pretty basic questions.
    What's your purpose?
    I – as well as many people here – could answer all your questions. Also, I could provide some misleading hints which could cause serious trouble for you in case you would use them in your exam.
    You should go a different route.

  • Urgent help with an exception !!

    Hi I Use a java class to calculate some data.
    This java class is called from a jsp page and first I create a Object from the class (and the constructor method is been called). In this constructor I recive (from the jsp page) a String[][] and other diferent values, but in this method I "copy" the String[][] I have passed to a Double [][] variable (defined like global) and I obtain an exception when the Sting[][] variable contains null vales. But I think I am treating that subject:
    JAVA CLASS:
    public class Functions_AEMult{
        Double [][] datosA;
        public Functions_AEMult( String [][] TablaFinal, String Frecuencia, String [] ValoresMult, HttpSession session)
            datosA = new Double[TablaFinal.length][2];
            for(int i = 0;i< TablaFinal.length;i++)
                if(null != TablaFinal[0])
    datosA [i][0] = new Double(TablaFinal[i][0]);
    if(null != TablaFinal[i][1])
    datosA [i][1] = new Double(TablaFinal[i][1]);
    The exception It gives me: ( In "[i]Functions_AEMult.java:884" the line is datosA [1] = new Double(TablaFinal[i][(j+1)]); )
    type Informe de Excepci�n
    mensaje
    descripci�n El servidor encontr� un error interno () que hizo que no pudiera rellenar este requerimiento.
    excepci�n
    org.apache.jasper.JasperException
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    causa ra�z
    java.lang.NullPointerException
         java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:980)
         java.lang.Double.valueOf(Double.java:202)
         java.lang.Double.<init>(Double.java:277)
         analisisEsp.Functions_AEMult.<init>(Functions_AEMult.java:884)
         org.apache.jsp.admin.PaleoPlot.show_jsp._jspService(show_jsp.java:928)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    nota La traza completa de la causa de este error se encuentra en los archivos de diario de Apache Tomcat/5.0.28.Some body can help me??
    thanks very much

    If you had some code comparing the entries for the String array to null, I would agree with you. But you don't. So you are calling new Double(null) and throwing that exception.Thanks for ur answer DrClap.
    when I do...
    if(null != TablaFinal[0])
    datosA [i][0] = new Double(TablaFinal[i][0]);
    if(null != TablaFinal[i][1])
    datosA [i][1] = new Double(TablaFinal[i][1]);
    I am comparing the entries for the String array to null, No?
    Thanks

  • Help with these!!!!

    hi,
    im doing these questions, im preparing for a test, and im not sure if my answers are correct or not, please help me find my errors:
    1- Which of the following methods must be over-ridden in order to tell the system how to execute a Thread?
    (A)     thread()
    (B)     execute()
    (C)     start()
    (D)     run()
    2- Which of the following is a correct event handling method?
    (A)          mousePressed(MouseEvent e){}
    (B)          MousePressed(MouseClick e){}
    (C)          functionKey(KeyPress k){}
    (D) ComponentAdded(keyPress e){}
    (3) A monitor called mon has 5 threads in its waiting pool; all these waiting threads have the same priority. One of the threads is thread1. How can you notify thread1 so that it alone moves from Waiting state to Ready State?
    (A) Execute notify(thread1); from within synchronized code of mon.
    (B) Execute mon.notify(thread1); from synchronized code of any
    object.
    (C) Execute thread1.notify(); from any code(synchronized or not) of
    any object.
    (D) You cannot specify which thread will get notified.
    (4) Which of the following best describes the use of the synchronized
    keyword?
    (A) Allows two processes to run in parallel but to communicate with
    each other.
    (B) Ensures only one thread at a time may access a method or object.
    (C) Ensures that two or more processes will start and end at the same
    time.
    (D) Ensures that two or more Threads will start and end at the same time.
    (5) How can you retrieve a circle?s radius value that?s passed to an applet?
    (A)
    public void init() {
    String s = getParameter("radius");
    doSomethingWithRadius(s); }
    (B)
    public static void main(String[] args) {
    String s = getParameter("radius");
    DoSomethingWithRadius(s); }
    (C)
    public void init() {
    int radius = getParameter("radius");
    doSomethingWithRadius(radius); }
    (D)
    public void init() {
    int radius = getParameter();
    doSomethingWithRadius(radius); }
    true/false
    1- The method drawRect(int a, int b, int c, int d) defined in
    java.awt draws the outline of a rectangle with a, b being the x,y coordinates of top left corner, and c,d being the x,y co-ordinates of the
    bottom right corner.
    TRUE
    2- There is no statement in Java to free storage.
    FALSE //finalize() is used
    These are some practice questions, since im preparing for a test. Once again im hoping that you guys may help me figure out if my answers are correct or not.
    Thanks in advance

    >
    1- Which of the following methods must be over-ridden
    in order to tell the system how to execute a Thread?
    (A)     thread()
    (B)     execute()
    (C)     start()
    (D)     run()Wrong. This was a particularl bad choice since that method doesn't even exist.
    2- Which of the following is a correct event handling
    method?
    (A)          mousePressed(MouseEvent e){}
    (B)          MousePressed(MouseClick e){}
    (C)          functionKey(KeyPress k){}
    (D)
    omponentAdded(keyPress e){}
    Wrong
    >
    >
    (3) A monitor called mon has 5 threads in its waiting
    pool; all these waiting threads have the same
    priority. One of the threads is thread1. How can you
    notify thread1 so that it alone moves from Waiting
    state to Ready State?
    (A) Execute notify(thread1); from within
    synchronized code of mon.
    (B) Execute mon.notify(thread1); from synchronized
    code of any
    object.
    (C) Execute thread1.notify(); from any
    code(synchronized or not) of
    any object.
    (D) You cannot specify which thread will get
    notified.Please consider reading the API and the threading tutorial before making wild guesses.
    >
    (4) Which of the following best describes the use of
    the synchronized
    keyword?
    (A) Allows two processes to run in parallel but to
    communicate with
    each other.
    (B) Ensures only one thread at a time may access a
    method or object.
    (C) Ensures that two or more processes will start and
    end at the same
    time.
    (D) Ensures that two or more Threads will start and
    end at the same time.
    Correct.
    (5) How can you retrieve a circle?s radius value
    that?s passed to an applet?
    (A)
    public void init() {
    String s = getParameter("radius");
    doSomethingWithRadius(s); }
    (B)
    public static void main(String[] args) {
    String s = getParameter("radius");
    DoSomethingWithRadius(s); }
    (C)
    public void init() {
    int radius = getParameter("radius");
    doSomethingWithRadius(radius); }
    (D)
    public void init() {
    int radius = getParameter();
    doSomethingWithRadius(radius); }
    Wrong
    true/false
    1- The method drawRect(int a, int b, int c, int d)
    defined in
    java.awt draws the outline of a rectangle with a, b
    being the x,y coordinates of top left corner, and c,d
    being the x,y co-ordinates of the
    bottom right corner.
    TRUE
    Wrong
    2- There is no statement in Java to free storage.
    FALSE //finalize() is used
    Hmmm. Your explanation is wrong. The answer... I guess I will agree with.
    You need ALOT more practice. Practice coding for one thing.

  • Help with these two loops

    Hi I hope someone can help me?
    I have these two loops, which at the moment prints out like this
    addr1, id, phone, lastname, firstname
    town, addr2, postcode, county, country
    [7,4,2,1,0]
    [9,8,6,5,3]
    the first two lines is what vector vv2 holds inside it.
    the second two line is what vector vv holds inside it.
    my problem is how can i get it to printout like this?
    [7,4,2,1,0]
    addr1, id, phone, lastname, firstname
    [9,8,6,5,3]
    town, addr2, postcode, county, country
    I hope someone can help me thanks
    nicky
    for (int ii2=0;ii2 < results2.size(); ii2++) {
                    vv2 = (Vector)results2.elementAt(ii2);     
                          ste2 = vv2.toString();
                             stb2 = new StringBuffer(ste2);
                             stb12 = new StringBuffer();
                             int is = stb2.length();
                             int is2 = is-2;
                             int is3 = is-1;
                             stb2.replace(0,1,"");
                             stb2.replace(is2,is3,"");
                             for(int i222 = 0; i222 < vv2.size(); i222++){
                                  stb12.append(",");
                                  stb12.append("?");
                                  stb12.replace(0,1,"");
                                  System.out.println(stb2);
    for (int ii = 0; ii < results.size(); ii++) {
        vv = (Vector)results.get(ii);
    System.out.println(vv);
    }

    You are using more for loops than you need to. If you just want to print out the element of one vector after the other then just put it in the same loop. Here try this:
    for (int ii2=0;ii2 < results2.size(); ii2++) {
                    vv2 = (Vector)results2.elementAt(ii2);     
                          ste2 = vv2.toString();
                             stb2 = new StringBuffer(ste2);
                             stb12 = new StringBuffer();
                             int is = stb2.length();
                             int is2 = is-2;
                             int is3 = is-1;
                             stb2.replace(0,1,"");
                             stb2.replace(is2,is3,"");
                             for(int i222 = 0; i222 < vv2.size(); i222++){
                                  stb12.append(",");
                                  stb12.append("?");
                                  stb12.replace(0,1,"");
                                  System.out.println(stb2);
         vv = (Vector)results.get(ii2);
         System.out.println(vv);
          And for god sakes man use some better names for your for loop iterator. Usually it is custom to start with i and if you need an inner for loop or another for loop within the same scope move on to using j and then k, so on and so on. All those numbers in your variables make the code harder to read than it needs to be. Just a suggestion, good luck.

  • Can anyone help with these annoyances

    Hi,
    I've used Logic since 2.4 and enjoyed its continued development and improvement up through Logic 7. Since the major retooling in Logic 8, I feel that it has become more buggy, less professional and genuinely less pleasurable to use. I've found work arounds (or just given up) on some things that used to be easy or even just "doable" in older version... Maybe some of you out there have some solutions to the following annoyances in Logic 9.x
    I wish it would/could;;;
    Return to last play position while in record. (worked fine on Logic 7)
    Copy Drag consistently instead of just moving the part (even though the help tag says "copy" it only drags, then often puts it a measure ahead of where I put it) (worked fine on Logic 7)
    Not Record audio while recording midi if an audio track is in "input" (worked fine on Logic 7)
    Could resize screen objects and things like I really want them to look (worked fine on Logic 7)
    Not have major lag times for things like renaming objects, deleting tracks in the arrange page, bouncing, opening 3rd party plug ins, (worked fine on Logic 7)
    Have freedom to put the loop browser anywhere I want (worked fine on Logic 7)
    Get key commands to work consistently (worked fine on Logic 7)
    Could assign record names globally instead of only on the track being recorded (worked fine on Logic 7)
    Have a visible tool bar for things like "pencil" "fade" "text" etc instead of a pull down menu (worked fine on Logic 7)
    Have visual feedback when I've armed the "Fade" tool (worked fine on Logic 7)
    Be able to choose fonts and sizes on individual score text objects (worked fine on Logic 7)
    Not have help tags constantly bugging me when I'm resizing or moving notes and objects (worked fine on Logic 7)
    Be able to create a new "audio object" in the environment (instead of having to copy something else and then reassign its purpose (worked fine on Logic 7)

    Dan,
    I can commiserate with you on most of these annoyances. Let's just say that we're kindred spirits in this regard. Hopefully I can help you alleviate some of these things that stick in your craw. I'll (try and) limit my comments to things that can be changed (as opposed to those which are "permanently broken"):
    Could resize screen objects and things like I really want them to look (worked fine on Logic 7)
    Plugin windows can be resized in L9. Aside from that, I'll (try to) stick to limiting my comments re those things that cannot be changed.
    Have a visible tool bar for things like "pencil" "fade" "text" etc instead of a pull down menu (worked fine on Logic 7)
    The variety of tools has been reduced (for your safety and well-being) to the lucky number of three, and that's only if you have the right click assigned as a tool. Otherwise you are limited to two. So it's still a palette, though compared to what we used to have it's kind of hard to swallow. In case you didn't notice, there's a pun in there. I almost missed it myself.
    I have my "V" key programmed to call up the toolbox. Its close proximity to the spacebar (play/stop) and the CMD key (for assigning a tool to) make it an ideal way to change tools without having to mouse all the way across the screen to access the unpalatable palette.
    Be able to choose fonts and sizes on individual score text objects (worked fine on Logic 7)
    This is still possible using the slow-to-appear, WYSI-not-WYG, icky-looking, way-too-small-font "Fonts" editor in the score editor. *Text > Fonts...* And because it's no longer even remotely as easy to resize text I've gotten into using the resize tool, as well as setting up various boilerplate text styles using the text styles editor. One thing that's nice though (hey, it's not all bad) is that you can import text styles from other projects.
    Not have help tags constantly bugging me when I'm resizing or moving notes and objects (worked fine on Logic 7)
    These can be disabled in the Logic prefs: *Prefs > Display > General*
    Be able to create a new "audio object" in the environment (instead of having to copy something else and then reassign its purpose (worked fine on Logic 7)
    You can still do this. Environment: *New > Channel Strip > Audio*
    The best thing about Logic 9 is flex editing. Othewise, gimme back L7 any day (minus the bugs, of course).

  • Can anyone help with these kernel panics?

    I work for the NHS.  Have spent most of my salary on Adobe Premiere Pro using a Intel Core Mac OS 10.5.8 which is supposed to be enough for the system requirements.  Have spent all day shutting down my computer unable to start the software.  If it does start it freezes and tells me to restart.  This is not acceptable.  Can anyone help??? Adobe cefrtai nly don't want to is there ahtyone out there with any solutions?  I ahve checked the hard drive it is fine, have done all the usual checks to no avail. Cannot find anywhere to talk to Adobe, their website is a minefield of Groundhog Day!
    I have the same problem with Photoshop purchased last year as part of a creative package.  This is really annoying!

    Dear Wonderspark,
    I am back at my iMac.  Here are the details of my hardware.
    Model Name:
    iMac
      Model Identifier:
    iMac7,1
      Processor Name:
    Intel Core 2 Duo
      Processor Speed:
    2.4 GHz
      Number Of Processors:
    1
      Total Number Of Cores:
    2
      L2 Cache:
    4 MB
      Memory:
    3 GB
      Bus Speed:
    800 MHz
      Boot ROM Version:
    IM71.007A.B03
      SMC Version (system):
    1.20f4
      Serial Number (system):
    W88035L3X86
      Hardware UUID:
    00000000-0000-1000-8000-001EC205D8B9
    Chipset Model:
    ATI,RadeonHD2600
      Type:
    Display
      Bus:
    PCIe
      PCIe Lane Width:
    x16
      VRAM (Total):
    256 MB
      Vendor:
    ATI (0x1002)
      Device ID:
    0x9583
      Revision ID:
    0x0000
      ROM Revision:
    113-B2250F-219
      EFI Driver Version:
    01.00.219
      Displays:
    iMac:
      Resolution:
    1680 x 1050
      Depth:
    32-Bit Color
      Core Image:
    Hardware Accelerated
      Main Display:
    Yes
      Mirror:
    Off
      Online:
    Yes
      Quartz Extreme:
    Supported
      Built-In:
    Yes
    The software versionas are as follows.
    Adobe Photoshop CS5 version 12.0.4
    Adobe Premiere Pro CS 5.5 version 5.5.0
    I hope that is more use.  As I said, the software is successfully installed, but I cannot open Premiere Pro.  Photoshop does open occasionally but rather like Russian roulette.
    I also have the Creative suite and Dreamweaver is no problem, neither is Indesign.  This makes no sense to me I would be grateful for any help.  I have checked the hardware and the system is ok.  I have tried re-installing the software after un-installing it but that made no difference.  I obviously have turned the machine on and off because of the black veil that descends upon the screen during the kernel panic.  Premiere Pro has alo frozen everything rather than causing a panic too. HELP!

  • Help with these java statements

    Can someone help me understand the following :
    "There are no errors but the loop terminates prematurely due to condition using the incorrect relational operator. The values of TotalVAT and TotalCosts will be 0.0."
    double[] Costs = {10.00, 20.00, 30.00, 15.00};double TotalCost = 0.0;double TotalVAT = 0.0;for (int Count = 0; Count > Costs.length; Count++) { double VAT = Costs[ Count ] * 0.175; TotalVAT = TotalVAT + VAT; TotalCost = TotalCost + Costs[ Count ] + VAT;}
    [\code]
    Thank you,

      double[] Costs = {10.00, 20.00, 30.00, 15.00};
      double TotalCost = 0.0;
      double TotalVAT = 0.0;
      for (int Count = 0; Count > Costs.length; Count++)
        double VAT = Costs[ Count ] * 0.175;
        TotalVAT = TotalVAT + VAT;
        TotalCost = TotalCost + Costs[ Count ] + VAT;
      }"the loop terminates prematurely" = the loop ends too early,
    it's not run as often as you think it would be. With loops that is
    often either once too few or not at all, in this case the latter.
    "due to condition using the incorrect relational operator" ->
    relational operators are operators that compare numbers (or other
    data), e.g. ==, !=, <, and >. There is only one relational operator
    here, it's >.
    For-loops work like this:
    for (init; cond; inc)
    init is the initialization, that's fine here: int Count = 0
    cond is a condition that has to be met everytime the loop starts from
    the beginning (not like in some other languages, where the condition is
    the one that will lead to the end of the loop). So here it checks
    whether Count > Costs.length is true and only then it will be executed.
    That's of course nonsense - you want to repeat that loop while Count is
    still less than Costs.length and you want to stop when it reaches
    Costs.length or goes above it, not the other way around. You loop will
    never execute at all! So simply replace the > with a <.
    (inc is the incrementation, that's fine here, too.)
    Say, who wrote that comment "There are no errors but the loop
    terminates prematurely due to condition using the incorrect relational
    operator. The values of TotalVAT and TotalCosts will be 0.0."? Was that
    a contest about being as verbose and ununderstandable as possible?
    A note: Only classes (and interfaces) start with capital letters. Use
    lower case letters for variables (and methods and packages): costs,
    totalCost, totalVAT, count, vat. (ALL CAPS are used for constants.)
    Hope this helps,
    Monika.

  • Help with nullPointer exception

    Hi,
    I would like some help identifying and error in the code below. Im getting a nullPointer exception at the location specified in the code. Im adding elements to a tableModel. What puzzles me is that the strings I add to the model does contain values. And it does not complain about adding them. Perhaps this is just a simple error, and you more experinced programmars are probably loughing at me ;)
    void getTests() {
          String[] idNummer = getDirectory(); //gets filenames from a directory
          for (int i = 0; i < idNummer.length; i++) {
             idNummer[i] = idNummer.substring(idNummer[i].lastIndexOf(dataSeparetor) + 1, idNummer[i].length());
    // just sorts out specific parts of the filenames
    for (int i = 0; i < idNummer.length; i ++) {
    System.out.println(idNummer[i]); //I print the sorted filenames and they not null
    testModel.addElement(idNummer[i]); //I add them to the table model
    testNr.setModel(testModel); //and gets a nullPoint exception here??

    I'm sorry, you mean testNr. Don't pay any attention to the above post. it is also declared directly in the class:
    public class GUI extends JFrame implements EventListener  {
      JList testModel;
    }and creates an instance here:
    public GUI {
    testModel = new DefaultListModel();
    getTests();
    testNr = new JList(testModel);
          testNr.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
          testNr.setLayoutOrientation(JList.VERTICAL);
          testNr.setPreferredSize(new Dimension(80, 80));
          testNr.addListSelectionListener(new ListSelectionListener() {
             public void valueChanged(ListSelectionEvent event) {
          leftPanel.add(testNr, BorderLayout.EAST);
    }

  • Help with the exception handling

    I have something like
    Node n = getNode();
    if (null == n) {
    throw new ServletException ("Missing or Incorrect Request");
    some extra code here
    catch (Exception e ) {
    logger.error(e);
    throw new ServletException ("Missing or Incorrect Request");
    I though that after throwing ServletException it would be caught in catch block and then will be thrown again so I can handle it in another method. Problem is that it is dies on line
    logger.error(e);
    I understand that it is better to specify exact exception instead of using parent Exception class, yet in theory I thought it should work.
    Can someone tell what is wrong here.
    Message was edited by:
    arushunter

    "Problem is that it is dies on line logger.error(e);"
    What does 'dies' mean? Is logger null? Is there another exception? Can you provide any more detailed info?
    You shouldn't catch any exception that you're not going to handle. Personally, I'm not crazy about logging and rethrowing the same thing. It's really not a servlet exception; it's an application exception that tells users when a request is malformed.
    Seems more like a validation issue to me. If you were using Spring, you'd have a validator that would check the input for correctness, add errors if any, and reroute the user back to the offending page with messages telling them how to correct the problem.
    %

  • Help with these buttons

    hi
    i am totaly stuck with this problem i have in flash MX
    i have a design which is enclosed in a frame produced in
    photoshop, the buttons around the frame need to load content to
    below the frame.
    to do this i made an empty fla file with just an action which
    loads the frame.swf to level 2
    everything is fine apart from the buttons i have in a movie
    clip, what ever i try doesnt seem to load the other content swf
    files
    this is the WIP site to look at,
    SITE
    LINK which will prob make sense of my explination...i hope
    i have tried _root. , _parent, almost anything really, i have
    done a search for this problem but the solutions i've come across
    dont work for me
    i must be missing something please help
    chris

    try giving your movieClips Instance names, and target them
    using that, instead of _root and _parent.
    if you want all your movies that are loaded externaly to be
    Below the frame, simply put your frame on the first or secont layer
    in your fla.
    If the frame itself is being loaded, you could set it's depth
    to something ridiculous like 1000, that way you are sure that
    nothing will load on top of it.
    also, when you have problems with code, it's always better to
    show the part of your code where the problem is, that would make it
    much easier for people in here to help you.

Maybe you are looking for