• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - Errone

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Below is my code and at the bottom is the error
How do i resolve the error?



/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Logins;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;







/**
*
* @author Admin
*/



public class Membership {//The Members Class
   
 MY_CONNECTION my_connection = new MY_CONNECTION();

       // Create a Function to add Members
   public boolean addMember(String MemberNumber, String LastName, String MiddleName, String FirstName, String DateOfBirth,
           String IDNumber, String DateOfMembership, String PostalAddress, String City, String County, String Citizenship,
           String Country, String EMailAddress, String CellPhone1, String CellPhone2)
   {
   PreparedStatement st;
   ResultSet rs;
   String addQuery = "INSERT  INTO Membership ('MemberNumber','LastName','MiddleName','FirstName','DateOfBirth','IDNumber','DateOfMembership','PostalAddress','City','County','Citizenship','Country','EmailAddress','CellPhone1','CellPhone2') VALUES"
           + "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
   
   st = my_connection.createConnection().prepareStatement(addQuery);
   
     try {
         st.setString(1, MemberNumber);
         st.setString(2, LastName);
         st.setString(3, MiddleName);
         st.setString(4, FirstName);
         st.setString(5, DateOfBirth);
         st.setString(6, IDNumber);
         st.setString(7, DateOfMembership);
         st.setString(8, PostalAddress);
         st.setString(9, City);
         st.setString(10, County);
         st.setString(11, Citizenship);
         st.setString(12, Country);
         st.setString(13, EMailAddress);
         st.setString(14, CellPhone1);
         st.setString(15, CellPhone2);
         
         if(st.executeUpdate()>0)
         {
           return true;
         }else{
             return false;
         }
         
         
   } catch (SQLException ex) {
         java.util.logging.Logger.getLogger(Membership.class.getName()).log(Level.SEVERE, null, ex);
 }
   
   // Create a function to edit the Membership Chosen
   
   //Create a Function to remove a selected Membership
   
   //create a function to return a list of all Members



Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: Logins.MY_CONNECTION
at Logins.Membership.<init>(Membership.java:28)
at Logins.NewMember.<init>(NewMember.java:19)
at Logins.NewMember$3.run(NewMember.java:460)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
BUILD SUCCESSFUL (total time: 6 seconds)



NEW ERROR
After amending the class
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - missing return statement
at Logins.Membership.addMember(Membership.java:34)
at Logins.NewMember.jButton1ActionPerformed(NewMember.java:355)
at Logins.NewMember.access$100(NewMember.java:14)
at Logins.NewMember$2.actionPerformed(NewMember.java:155)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6539)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
BUILD SUCCESSFUL (total time: 22 seconds)

     



   
   





 
Marshal
Posts: 74054
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I tried adding code tags to your post, but the very long lines became illegible, and I gave up. Please show us which line the exception blames for the compiler error.
 
Campbell Ritchie
Marshal
Posts: 74054
332
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please show us where the MY_CONNECTION class is (that is not a good class name, I am afraid).
Don't write if (something) return true; else return false;
Write return st.executeUpdate() > 0;
 
Philo Mug
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Line 34 and Line 14

Membership.java class
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Logins;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;








     
 
Campbell Ritchie
Marshal
Posts: 74054
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure you have the same line numbers? I would have thought line 10 if the problem is to do with MY_CONNECTION.
 
Saloon Keeper
Posts: 24325
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You do not have a return statement for your "catch" logic or logic that might be following the try/catch. When you catch an Exception, you land in the logic of the method containing the "catch" and are returned to normal execution flow, which means that if the method was declared as returning a value, the logic following the catch action must also return a value, because ALL normal execution exits from a method must be conformant with the method declaration.

If you don't code an explicit return at the bottom of your method code, a void return statement is assumed.

Nitpick:


Is more succinct (and slightly less error-prone) as:
 
reply
    Bookmark Topic Watch Topic
  • New Topic