Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 15 of 15

Thread: Need help with error message!!

  1. #1
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Need help with error message!!

    I am receiving the following error message when I compile my code and I have no idea how to fix it. Please help.

    Scanning for modules in C:\Program Files (x86)\NetBeans 7.2.1\platform
    Scanning for modules in suite C:\Users\Me\Documents\SampleCRUDApp\Donor Info
    init:
    up-to-date:
    compile:
    Created dir: C:\Users\Me\Documents\SampleCRUDApp\Donor Info\DonorViewer\build\classes
    Compiling 1 source file to C:\Users\Me\Documents\SampleCRUDApp\Donor Info\DonorViewer\build\classes
    warning: No processor claimed any of these annotations: [javax.annotation.Generated]
    C:\Users\Me\Documents\SampleCRUDApp\Donor Info\DonorViewer\src\org\shop\viewer\DonorViewerTo pComponent.java:51: warning: [unchecked] unchecked conversion
    found : java.util.List
    required: java.util.List<donorinfo.Donors>
    List<Donors> resultList = query.getResultList();
    1 warning



    The result of the code is to read data from a database and display the contents in a Jtextarea window. The Jtextarea window generates, but no data is displayed.

    Here is the complete code:

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package org.shop.viewer;
     
    import donorinfo.Donors;
    import java.util.List;
    import javax.persistence.EntityManager;
    import javax.persistence.Persistence;
    import javax.persistence.Query;
    import org.netbeans.api.settings.ConvertAsProperties;
    import org.openide.awt.ActionID;
    import org.openide.awt.ActionReference;
    import org.openide.util.NbBundle.Messages;
    import org.openide.windows.TopComponent;
     
     
    /**
     * Top component which displays something.
     */
    @ConvertAsProperties(
        dtd = "-//org.shop.viewer//DonorViewer//EN",
    autostore = false)
    @TopComponent.Description(
        preferredID = "DonorViewerTopComponent",
    //iconBase="SET/PATH/TO/ICON/HERE", 
    persistenceType = TopComponent.PERSISTENCE_ALWAYS)
    @TopComponent.Registration(mode = "explorer", openAtStartup = true)
    @ActionID(category = "Window", id = "org.shop.viewer.DonorViewerTopComponent")
    @ActionReference(path = "Menu/Window" /*, position = 333 */)
    @TopComponent.OpenActionRegistration(
        displayName = "#CTL_DonorViewerAction",
    preferredID = "DonorViewerTopComponent")
    @Messages({
        "CTL_DonorViewerAction=DonorViewer",
        "CTL_DonorViewerTopComponent=DonorViewer Window",
        "HINT_DonorViewerTopComponent=This is a DonorViewer window"
     
    })
     
     
    public final class DonorViewerTopComponent extends TopComponent {
     
        public DonorViewerTopComponent() {
            initComponents();
            setName(Bundle.CTL_DonorViewerTopComponent());
            setToolTipText(Bundle.HINT_DonorViewerTopComponent());
    EntityManager entityManager = Persistence.createEntityManagerFactory("DonorInfoLibraryPU").createEntityManager();
    Query query = entityManager.createNamedQuery("Donors.findAll");
    List<Donors> resultList = query.getResultList();
    for (Donors c : resultList) {
      jTextArea1.append(c.getName() + " (" + c.getAmount() + "(" + c.getCharity() +")" + "\n");
    }
        }
     
        /**
         * This method is called from within the constructor to initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is always
         * regenerated by the Form Editor.
         */
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
     
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
     
            jTextArea1.setColumns(20);
            jTextArea1.setRows(5);
            jScrollPane1.setViewportView(jTextArea1);
     
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(112, 112, 112)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(122, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(70, 70, 70)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(134, Short.MAX_VALUE))
            );
        }// </editor-fold>
     
        // Variables declaration - do not modify
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTextArea jTextArea1;
        // End of variables declaration
        @Override
        public void componentOpened() {
            // TODO add custom code on component opening
        }
     
        @Override
        public void componentClosed() {
            // TODO add custom code on component closing
        }
     
        void writeProperties(java.util.Properties p) {
            // better to version settings since initial version as advocated at
            // [url]http://wiki.apidesign.org/wiki/PropertyFiles[/url]
            p.setProperty("version", "1.0");
            // TODO store your settings
        }
     
        void readProperties(java.util.Properties p) {
            String version = p.getProperty("version");
            // TODO read your settings according to their version
        }
    }
    Attached Images Attached Images


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Need help with error message!!

    Please post the source code for the lines where the compiler is saying there is an error.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Need help with error message!!

    It is in this section here: Specifically, the line in red.


    public final class DonorViewerTopComponent extends TopComponent {

    public DonorViewerTopComponent() {
    initComponents();
    setName(Bundle.CTL_DonorViewerTopComponent());
    setToolTipText(Bundle.HINT_DonorViewerTopComponent ());
    EntityManager entityManager = Persistence.createEntityManagerFactory("DonorInfoL ibraryPU").createEntityManager();
    Query query = entityManager.createNamedQuery("Donors.findAll");
    List<Donors> resultList = query.getResultList();
    for (Donors c : resultList) {
    jTextArea1.append(c.getName() + " (" + c.getAmount() + "(" + c.getCharity() +")" + "\n");
    }

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Need help with error message!!

    found : java.util.List
    required: java.util.List<donorinfo.Donors>
    What does the getResultList() method return?
    Is it a List<Donors> object?
    Or just a List?

    The compiler wants a List<Donors> object (the required: item).
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Need help with error message!!

    The list should just display the names of the donors, their donation amount, and the charity name. Those are the only 3 fields in the database under the "donors" table.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Need help with error message!!

    What data type is the object returned by the getResultList() method?
    The variable to the left of the = should be the same data type.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Need help with error message!!

    The data is just text data from a database file. VARCHAR is the type.

    Is that what you are asking?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Need help with error message!!

    Look at the definition for the getResultList() method. What is it defined to return?
    For example this method is defined to return a String:
    public String getActionCommand() {
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Need help with error message!!

    Sorry.... I'm not understanding. The getResultList() method is defined to return string data in a query.

    What does the code need to say in order to pull the data from the database?

  10. #10
    Member
    Join Date
    Jul 2012
    Posts
    71
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Default Re: Need help with error message!!

    its giving you an error because something is flawed in your when you call List<Donors> resultList = query.getResultList(); the compiler says it requires java.util.List<donorinfo.Donors> but it is finding only java.util.List... i suggest taking a look at the donorinfo.Donor package that you are importing

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Need help with error message!!

    getResultList() method is defined to return string
    If that we true you would code:
    String aString = query.getResultList();

    Can you ask some help from the person that wrote the code you are working with?
    If you don't understand my answer, don't ignore it, ask a question.

  12. #12
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Need help with error message!!

    Quote Originally Posted by Norm View Post
    If that we true you would code:
    String aString = query.getResultList();

    Can you ask some help from the person that wrote the code you are working with?
    No one helped me build the code. I'm using NetBeans IDe and their CRUD tutorial to build the project.

    I just noticed another error message in the output window that says: "Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/Donor Info"

    Donor Info is the name of the database. I pointed the IDE to the name of the derbyclient.jar file in the NetBeans folder that it created for this file. Specifically: "...Documents\SampleCRUDApp\build\cluster\modules\ ext"

    Since I am not getting any compile errors, and since the text area window is opening okay (but not displaying any data), i am assuming the derbyclient.jar file is the issue.

    How can I get this jar file issue fixed?

  13. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Need help with error message!!

    The error posted in post #1 is a compiler error. The compiler says this line is not correctly coded:
    List<Donors> resultList = query.getResultList();

    The getResultList() is not defined to return a List<Donors> object.

    I have no idea how to configure your IDE.
    If you don't understand my answer, don't ignore it, ask a question.

  14. #14
    Member
    Join Date
    Jan 2013
    Posts
    37
    My Mood
    Confused
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Need help with error message!!

    How do I define it to return the List <Donors> object?

  15. #15
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Need help with error message!!

    First find where the source for the method is. Without the source you will not be able to change it.

    If it is in a class with generic definitions, you might be able to define the class with a generic that will then define the method to return the List<Donors>.

    If you can't make those changes, remove the <Donors> from the List declaration and make resultList a plain List.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Error message when using JOptionPane
    By runkerr in forum What's Wrong With My Code?
    Replies: 7
    Last Post: February 5th, 2013, 12:17 PM
  2. [SOLVED] Help making an error message.
    By Lost_Secret in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 1st, 2011, 04:48 PM
  3. Strange error message
    By javapenguin in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 11th, 2011, 02:03 PM
  4. an error message while runnung java
    By sravan_kumar343 in forum Java Theory & Questions
    Replies: 1
    Last Post: January 25th, 2010, 10:19 AM
  5. help with a error message
    By JavaNoob82 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 23rd, 2010, 02:56 PM