Win a copy of Java Challengers this week in the Java in General forum!

Philo Mug

Greenhorn
+ Follow
since Feb 04, 2021
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Philo Mug

3 months ago
I have attached a file with the screenshots


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;








     
3 months ago
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)

     



   
   





3 months ago