Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I am having issue with this code, having error, says Connection con is null, rest of the code in comment. import javax.swing.*; import java.awt.event.ActionEvent;

Hello I am having issue with this code, having error, says "Connection con is null", rest of the code in comment.

import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.*; import java.util.ArrayList; import java.util.List; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.DriverManager; public class Test2 { //Se crea variables private String fname; private String lname; private String mail; private String dobirth; private String com; int pos = 0; //variables del GUI private JPanel Main; private JButton first; private JButton previous; private JButton next; private JButton last; private JButton addnew; private JButton delete; private JButton selectprinter; private JButton exit; private JTextField txtname; private JTextField txtlastname; private JTextField txtemail; private JTextField txtdob; private JTextArea txtcomment; private JLabel name; private JLabel lastname; private JLabel email; private JLabel dateofbirth; private JLabel comment; public Test2(String _fname, String _lname, String _mail, String _dobirth, String _com) { this.fname = _fname; this.lname = _lname; this.mail = _mail; this.dobirth = _dobirth; this.com = _com; } public String getFname() { return fname; } public void setFname(String fname) { this.fname = fname; } public String getLname() { return lname; } public void setLname(String lname) { this.lname = lname; } public String getMail() { return mail; } public void setMail(String mail) { this.mail = mail; } public String getDobirth() { return dobirth; } public void setDobirth(String dobirth) { this.dobirth = dobirth; } public String getCom() { return com; } public void setCom(String com) { this.com = com; } Connection con; PreparedStatement pst; ResultSet rs; public static Connection getConnection() { Connection cn;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managerial Accounting Decision Making and Performance Management

Authors: Ray Proctor

4th edition

273764489, 978-0273764489

More Books

Students also viewed these Programming questions