问题描述
- java.lang.NullPointerException
-
package ch12;import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;@SuppressWarnings("serial")
public class adminUser extends JFrame implements ActionListener {
JMenuBar menu;
JMenu me, me1, me2, me3, me4;
JMenuItem item, item3, item4, item5, item6, item7;
JMenuItem item8, item9, item10, item11, item12, item13, item14;
JMenuItem item15, item16, item17, item18, item19, item21;
JMenuItem item22, item23;
JLabel hintLabel;
JTextField inputNumber;
Object name[] = { "部门编号" };
Object a[][] = new Object[1][1];
JTable table;
JButton enterModify;
JLabel hintLabel3;
JTextField inputNumber3;
Object name3[] = { "工龄等级", "技术等级" };
Object a3[][] = new Object[1][2];
JTable table3;
JButton enterModify3;
JLabel hintLabel4;
JTextField inputnum4;
Object name4[] = { "出勤类别", "系数" };
Object a4[][] = new Object[1][2];
JTable table4;
JButton enter4;
JLabel hintLabel5;
JTextField inputnum5;
Object name5[] = { "津贴类别", "津贴款数" };
Object a5[][] = new Object[1][2];
JTable table5;
JButton enter5;
JLabel hintLabel6;
JTextField inputnum6;
Object name6[] = { "款数" };
Object a6[][] = new Object[1][1];
JTable table6;
JButton enter6;
JLabel hintLabel7;
JTextField inputnum7;
Object name7[] = { "款数" };
Object a7[][] = new Object[1][1];
JTable table7;
JButton enter7;
JLabel hintLabel8;
Object name8[] = { "员工号", "姓名", "性别", "出生日期(格式日/月/年)", "文化程度", "民族", "籍贯",
"地址", "人员级别", "部门编号", "技术等级"};
Object a8[][] = new Object[1][11];
JTable table8;
JButton enterInsert8;
JLabel hintLabel9;
Object name9[] = { "员工号", "出勤类别号", "出勤天数" };
Object a9[][] = new Object[1][3];
JTable table9;
JButton enterInsert9;
JLabel hintLabel10;
Object name10[] = { "员工号", "津贴类别号" };
Object a10[][] = new Object[1][2];
JTable table10;
JButton enterInsert10;
JLabel hintLabel11;
Object name11[] = { "出勤编号", "出勤类别", "计算系数" };
Object a11[][] = new Object[1][3];
JTable table11;
JButton enterInsert11;
JLabel hintLabel12;
Object name12[] = { "津贴编号", "津贴名称", "款数" };
Object a12[][] = new Object[1][3];
JTable table12;
JButton enterInsert12;
JLabel hintLabel13;
Object name13[] = { "工龄等级", "款数" };
Object a13[][] = new Object[1][2];
JTable table13;
JButton enterInsert13;
JLabel hintLabel14;
Object name14[] = { "职务等级", "款数" };
Object a14[][] = new Object[1][2];
JTable table14;
JButton enterInsert14;
JLabel hintLabel15;
Object name15[] = { "员工编号", "出勤信息", "出勤天数", "计算系数" };
Object a15[][] = new Object[1][4];
JTable table15;
JButton enterInsert15;
JLabel hintLabel16;
Object name16[] ={ "员工编号", "津贴款数", "津贴信息" };
Object a16[][] = new Object[1][3];
JTable table16;
JButton enterInsert16;
JLabel hintLabel17;
Object name17[] = { "员工编号", "基本工资" };
Object a17[][] = new Object[1][2];
JTable table17;
JButton enterInsert17;JLabel jl18; JTextField jtf18; JButton jb18; Object a18[][] = new Object[1][14]; Object name18[] = { "职工编号", "基本工资", "岗位津贴", "物价补贴", "住房补贴", "日班费", "夜班费", "假期加班", "房租", "病假扣款", "事假扣款", "旷工扣款", "其他扣款", "实发工资" }; JTable table18; JButton jj19; JTextField jt19; Object a19[][] = new Object[1][2]; Object name19[] = { "员工编号", "工资" }; JTable table19; Object a20[][] = new Object[1][2]; Object name20[] = { "部门工资", "部门编号" }; JTable table20; JLabel hintLabel21; JTextField inputNumber21; JButton jb21; JButton jj22, jb22; JTextField jt22, jl22; Object a22[][] = new Object[1][3]; Object name22[] = { "员工编号", "出勤编号", "天数" }; JTable table22; JButton jj23, jb23; JTextField jt23, jl23; Object a23[][] = new Object[1][2]; Object name23[] = { "员工编号", "津贴" }; JTable table23; JPanel jp; Connection con; Statement sql, sql1; ResultSet rs, rs1; String num; CallableStatement cstmt = null; adminUser() { this.setTitle("管理员用户"); menu = new JMenuBar(); me = new JMenu("修改"); me1 = new JMenu("添加信息"); me2 = new JMenu("显示"); me3 = new JMenu("统计"); me4 = new JMenu("删除"); item = new JMenuItem("职工部门"); item3 = new JMenuItem("职工基本工资信息"); item4 = new JMenuItem("出勤信息"); item5 = new JMenuItem("津贴信息"); item6 = new JMenuItem("工龄——工资"); item7 = new JMenuItem("职务——工资"); item8 = new JMenuItem("职工信息"); item9 = new JMenuItem("职工出勤情况"); item10 = new JMenuItem("职工津贴信息"); item11 = new JMenuItem("出勤信息"); item12 = new JMenuItem("津贴信息"); item13 = new JMenuItem("工龄——工资"); item14 = new JMenuItem("职务——工资"); item15 = new JMenuItem("职工出勤情况"); item16 = new JMenuItem("职工津贴信息"); item17 = new JMenuItem("职工基本工资信息"); item18 = new JMenuItem("职工工资"); item19 = new JMenuItem("部门工资");
// item20 = new JMenuItem("总厂工资");
item21 = new JMenuItem("职工信息"); item22 = new JMenuItem("职工出勤信息"); item23 = new JMenuItem("职工津贴信息"); item.addActionListener(this); item3.addActionListener(this); item4.addActionListener(this); item5.addActionListener(this); item6.addActionListener(this); item7.addActionListener(this); item8.addActionListener(this); item9.addActionListener(this); item10.addActionListener(this); item11.addActionListener(this); item12.addActionListener(this); item13.addActionListener(this); item14.addActionListener(this); item15.addActionListener(this); item16.addActionListener(this); item17.addActionListener(this); item18.addActionListener(this); item19.addActionListener(this);
// item20.addActionListener(this);
item21.addActionListener(this); item22.addActionListener(this); item23.addActionListener(this); me.add(item); me.add(item3); me.add(item4); me.add(item5); me.add(item6); me.add(item7); me1.add(item8); me1.add(item9); me1.add(item10); me1.add(item11); me1.add(item12); me1.add(item13); me1.add(item14); me2.add(item15); me2.add(item16); me2.add(item17); me3.add(item18); me3.add(item19);
// me3.add(item20);
me4.add(item21); me4.add(item22); me4.add(item23); menu.add(me); menu.add(me1); menu.add(me2); menu.add(me3); menu.add(me4); this.setJMenuBar(menu); this.setVisible(true); this.setSize(400,300); Dimension d = this.getToolkit().getScreenSize(); this.setLocation((d.width - this.getWidth())/2, (d.height - this.getHeight())/2-100); //this.setBounds(10, 10, 200, 200); this.validate(); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } public void actionPerformed(ActionEvent e) { //修改职工部门 if (e.getSource() == item) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel = new JLabel("输入员工编号(回车确认):"); inputNumber = new JTextField(40); table = new JTable(a, name); enterModify = new JButton("更新记录"); jp.setLayout(null); Box baseBox = Box.createHorizontalBox(); baseBox.add(hintLabel); baseBox.add(inputNumber); baseBox.add(new JScrollPane(table)); baseBox.add(enterModify); jp.add(baseBox); baseBox.setBounds(10, 40, 550, 38); this.add(jp); inputNumber.addActionListener(this); enterModify.addActionListener(this); setBounds(20, 60, 600, 200); this.validate(); } //修改 职工基本工资信息 else if (e.getSource() == item3) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel3 = new JLabel("输入员工编号(回车确认):"); inputNumber3 = new JTextField(20); table3 = new JTable(a3, name3); enterModify3 = new JButton("更新记录"); jp.setLayout(null); Box baseBox = Box.createHorizontalBox(); baseBox.add(hintLabel3); baseBox.add(inputNumber3); baseBox.add(new JScrollPane(table3)); baseBox.add(enterModify3); jp.add(baseBox); baseBox.setBounds(10, 40, 550, 38); this.add(jp); inputNumber3.addActionListener(this); enterModify3.addActionListener(this); this.validate(); } //修改 出勤信息 else if (e.getSource() == item4) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel4 = new JLabel("输入类别号(回车确认)"); inputnum4 = new JTextField(20); table4 = new JTable(a4, name4); enter4 = new JButton("更新记录"); jp.setLayout(null); Box basebox = Box.createHorizontalBox(); basebox.add(hintLabel4); basebox.add(inputnum4); basebox.add(new JScrollPane(table4)); basebox.add(enter4); jp.add(basebox); basebox.setBounds(10, 40, 550, 38); this.add(jp); setBounds(20, 60, 700, 200); this.validate(); inputnum4.addActionListener(this); enter4.addActionListener(this); } //修改 津贴信息 else if (e.getSource() == item5) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel5 = new JLabel("输入类别号(回车确认)"); inputnum5 = new JTextField(20); table5 = new JTable(a5, name5); enter5 = new JButton("更新记录"); jp.setLayout(null); Box basebox = Box.createHorizontalBox(); basebox.add(hintLabel5); basebox.add(inputnum5); basebox.add(new JScrollPane(table5)); basebox.add(enter5); jp.add(basebox); basebox.setBounds(10, 40, 550, 38); this.add(jp); setBounds(20, 60, 700, 200); this.validate(); this.setVisible(true); inputnum5.addActionListener(this); enter5.addActionListener(this); } //修改 工龄——工资 else if (e.getSource() == item6) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel6 = new JLabel("输入工龄等级(回车确认)"); inputnum6 = new JTextField(20); table6 = new JTable(a6, name6); enter6 = new JButton("更新记录"); jp.setLayout(null); Box basebox = Box.createHorizontalBox(); basebox.add(hintLabel6); basebox.add(inputnum6); basebox.add(new JScrollPane(table6)); basebox.add(enter6); jp.add(basebox); basebox.setBounds(10, 40, 550, 38); this.add(jp); inputnum6.addActionListener(this); enter6.addActionListener(this); setBounds(20, 60, 700, 200); this.validate(); } //修改 职务——工资 else if (e.getSource() == item7) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel7 = new JLabel("输入职务等级(回车确认)"); inputnum7 = new JTextField(20); table7 = new JTable(a7, name7); enter7 = new JButton("更新记录"); jp.setLayout(null); Box basebox = Box.createHorizontalBox(); basebox.add(hintLabel7); basebox.add(inputnum7); basebox.add(new JScrollPane(table7)); basebox.add(enter7); jp.add(basebox); this.add(jp); basebox.setBounds(10, 40, 550, 38); inputnum7.addActionListener(this); enter7.addActionListener(this); setBounds(20, 60, 700, 200); this.validate(); } //添加职工信息 else if (e.getSource() == item8) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel8 = new JLabel("输入新记录:"); table8 = new JTable(a8, name8); enterInsert8 = new JButton("插入新记录"); jp.setLayout(null); Box baseBox = Box.createHorizontalBox(); baseBox.add(hintLabel8); baseBox.add(new JScrollPane(table8)); baseBox.add(enterInsert8); jp.add(baseBox); baseBox.setBounds(10, 40, 800, 38); this.add(jp); enterInsert8.addActionListener(this); setBounds(120, 160, 850, 200); this.validate(); } //添加职工出勤情况 else if (e.getSource() == item9) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel9 = new JLabel("输入新信息:"); table9 = new JTable(a9, name9); enterInsert9 = new JButton("插入新信息"); jp.setLayout(null); Box baseBox = Box.createHorizontalBox(); baseBox.add(hintLabel9); baseBox.add(new JScrollPane(table9)); baseBox.add(enterInsert9); jp.add(baseBox); baseBox.setBounds(10, 40, 500, 38); this.add(jp); enterInsert9.addActionListener(this); setBounds(120, 160, 550, 200); this.validate(); } //添加职工津贴信息 else if (e.getSource() == item10) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel10 = new JLabel("输入新信息:"); table10 = new JTable(a10, name10); enterInsert10 = new JButton("插入新信息"); jp.setLayout(null); Box baseBox = Box.createHorizontalBox(); baseBox.add(hintLabel10); baseBox.add(new JScrollPane(table10)); baseBox.add(enterInsert10); jp.add(baseBox); baseBox.setBounds(10, 40, 500, 38); this.add(jp); enterInsert10.addActionListener(this); setBounds(120, 160, 550, 200); this.validate(); } //添加出勤信息 else if (e.getSource() == item11) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel11 = new JLabel("输入新信息:"); table11 = new JTable(a11, name11); enterInsert11 = new JButton("插入新信息"); jp.setLayout(null); Box baseBox = Box.createHorizontalBox(); baseBox.add(hintLabel11); baseBox.add(new JScrollPane(table11)); baseBox.add(enterInsert11); jp.add(baseBox); baseBox.setBounds(10, 40, 500, 38); this.add(jp); enterInsert11.addActionListener(this); setBounds(120, 160, 550, 200); this.validate(); } //添加津贴信息 else if (e.getSource() == item12) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel12 = new JLabel("输入新信息:"); table12 = new JTable(a12, name12); enterInsert12 = new JButton("插入新信息"); jp.setLayout(null); Box baseBox = Box.createHorizontalBox(); baseBox.add(hintLabel12); baseBox.add(new JScrollPane(table12)); baseBox.add(enterInsert12); jp.add(baseBox); baseBox.setBounds(10, 40, 500, 38); this.add(jp); enterInsert12.addActionListener(this); setBounds(120, 160, 550, 200); this.validate(); } //添加工龄——工资 else if (e.getSource() == item13) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel13 = new JLabel("输入新信息:"); table13 = new JTable(a13, name13); enterInsert13 = new JButton("插入新信息"); jp.setLayout(null); Box baseBox = Box.createHorizontalBox(); baseBox.add(hintLabel13); baseBox.add(new JScrollPane(table13)); baseBox.add(enterInsert13); jp.add(baseBox); baseBox.setBounds(10, 40, 500, 38); this.add(jp); enterInsert13.addActionListener(this); setBounds(120, 160, 550, 200); this.validate(); } //添加 职务——工资 else if (e.getSource() == item14) { this.getContentPane().removeAll(); jp = new JPanel(); hintLabel14 = new JLabel("输入新信息:"); table14 = new JTable(a14, name14); enterInsert14 = new JButton("插入新信息"); jp.setLayout(null); Box baseBox = Box.createHorizontalBox(); baseBox.add(hintLabel14); baseBox.add(new JScrollPane(table14)); baseBox.add(enterInsert14); jp.add(baseBox); baseBox.setBounds(10, 40, 500, 38); this.add(jp); enterInsert14.addActionListener(this); setBounds(120, 160, 550, 200); this.validate(); } //显示 职工出勤情况 else if (e.getSource() == item15) { this.getContentPane().removeAll(); jp = new JPanel(); try { con = getConnection(); sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = sql.executeQuery("SELECT * FROM CalEmpAndPre"); rs.last(); int lastNumber = rs.getRow(); a15 = new Object[lastNumber][4]; int k = 0; rs.beforeFirst(); while (rs.next()) { a15[k][0] = rs.getString(1); a15[k][1] = rs.getString(3); a15[k][2] = rs.getString(4); a15[k][3] = rs.getDouble(5); k++; } con.close(); } catch (SQLException ee) { System.out.println(ee); } table15 = new JTable(a15, name15); jp.setLayout(new BorderLayout()); jp.add(new JScrollPane(table15), BorderLayout.CENTER); this.add(jp); setBounds(120, 160, 550, 200); this.validate(); } //显示职工津贴信息 else if (e.getSource() == item16) { this.getContentPane().removeAll(); jp = new JPanel(); try { con = getConnection(); sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = sql.executeQuery("SELECT * FROM CalEmpAndJintie"); rs.last(); int lastNumber = rs.getRow(); a16 = new Object[lastNumber][3]; int k = 0; rs.beforeFirst(); while (rs.next()) { a16[k][0] = rs.getString(1); a16[k][1] = rs.getDouble(3); a16[k][2] = rs.getString(4); k++; } con.close(); } catch (SQLException ee) { System.out.println(ee); } table16 = new JTable(a16, name16); jp.setLayout(new BorderLayout()); jp.add(new JScrollPane(table16), BorderLayout.CENTER); this.add(jp); setBounds(120, 160, 550, 200); this.validate(); } //显示职工基本工资信息 else if (e.getSource() == item17) { this.getContentPane().removeAll(); jp = new JPanel(); try { con = getConnection(); sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = sql.executeQuery("SELECT * FROM CalEmpAndSal"); rs.last(); int lastNumber = rs.getRow(); a17 = new Object[lastNumber][2]; int k = 0; rs.beforeFirst(); while (rs.next()) { a17[k][0] = rs.getString(1); a17[k][1] = rs.getDouble(2) + rs.getDouble(3); // System.out.println("update EmpAndSal set emp_salary="+Double.parseDouble(a[k][1].toString())+" where emp_salEmpNO='"+a[k][0]+"'"); String s = new String("update EmpAndSal set emp_salary=" + Double.parseDouble(a17[k][1].toString()) + " where emp_salEmpNO='" + a17[k][0] + "'"); Statement m = con.createStatement(); m.executeUpdate(s); k++; } con.close(); } catch (SQLException ee) { System.out.println(ee); } table17 = new JTable(a17, name17); jp.setLayout(new BorderLayout()); jp.add(new JScrollPane(table17), BorderLayout.CENTER); this.add(jp); setBounds(120, 160, 550, 200); this.validate(); } //统计职工工资 else if (e.getSource() == item18) { this.getContentPane().removeAll(); jp = new JPanel(); try { con = getConnection(); con.setAutoCommit(false); sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); sql1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs1 = sql1.executeQuery("SELECT emp_No FROM employees"); rs1.last(); int lastNumber = rs1.getRow(); a18 = new Object[lastNumber][14]; rs1.beforeFirst(); int k = 0; while (rs1.next()) { String m = rs1.getString(1); // System.out.println(m+""); // System.out.println("SELECT emp_salary FROM EmpAndSal WHERE emp_salEmpNo='"+m+"'"); rs = sql.executeQuery("SELECT emp_salary FROM EmpAndSal WHERE emp_salEmpNo='" + m + "'"); a18[k][0] = m; a18[k][1] = 0; a18[k][2] = 0; a18[k][3] = 0; a18[k][4] = 0; a18[k][5] = 0; a18[k][6] = 0; a18[k][7] = 0; a18[k][8] = 0; a18[k][9] = 0; a18[k][10] = 0; a18[k][11] = 0; a18[k][12] = 0; a18[k][13] = 0; rs.beforeFirst(); while (rs.next()) { a18[k][1] = rs.getDouble(1); } double s = Double.parseDouble(a18[k][1].toString()) / 24; double sum = 0; rs = sql.executeQuery("SELECT jin_No,jin_Money,jin_Name FROM CalEmpAndJintie WHERE emp_jinEmpNo='" + m + "'"); //查询津贴 while (rs.next()) { int pr = rs.getInt(1); if (pr == 1) { a18[k][2] = rs.getDouble(2); } else if (pr == 2) { a18[k][3] = rs.getDouble(2); } else if (pr == 3) { a18[k][4] = rs.getDouble(2); } else if (pr == 4) { a18[k][8] = rs.getDouble(2); } } rs = sql.executeQuery("SELECT pre_No,emp_prePreDays,pre_Xishu FROM CalEmpAndPre WHERE emp_preEmpNo='" + m + "'"); //查询出勤 while (rs.next()) { int pre = rs.getInt(1); if (pre == 6) { a18[k][5] = rs.getDouble(2) * s * rs.getDouble(3); } else if (pre == 7) { a18[k][6] = rs.getDouble(2) * s * rs.getDouble(3); } else if (pre == 8) { a18[k][7] = rs.getDouble(2) * s * rs.getDouble(3); } else if (pre == 3) { a18[k][9] = rs.getDouble(2) * s * rs.getDouble(3); } else if (pre == 5) { a18[k][10] = rs.getDouble(2) * s * rs.getDouble(3); } else if (pre == 4) { a18[k][11] = rs.getDouble(2) * s * rs.getDouble(3); } else { sum = sum + rs.getDouble(2) * s * rs.getDouble(3); } } a18[k][12] = sum; a18[k][13] = sum + Double.parseDouble(a18[k][1].toString()) + Double.parseDouble(a18[k][2].toString()) + Double.parseDouble(a18[k][3].toString()) + Double.parseDouble(a18[k][4].toString()) + Double.parseDouble(a18[k][5].toString()) + Double.parseDouble(a18[k][6].toString()) + Double.parseDouble(a18[k][7].toString()) + Double.parseDouble(a18[k][8].toString()) + Double.parseDouble(a18[k][9].toString()) + Double.parseDouble(a18[k][10].toString()) + Double.parseDouble(a18[k][11].toString()); int re = sql.executeUpdate("Update EmpAndRSal SET emp_rsalary=" + Double.parseDouble(a18[k][13].toString()) + " WHERE emp_rsalEmpNo='" + m + "'"); k++; if(re == 1) System.out.println(m + "的实际工资更新成功了"); else System.out.println(m + "的实际工资更新失败了"); } con.commit(); con.close(); } catch (SQLException ee) { try { con.rollback(); } catch (SQLException e1) { System.out.println(e1); } } table18 = new JTable(a18, name18); jp.setLayout(new BorderLayout()); jp.add(new JScrollPane(table18), BorderLayout.CENTER); this.add(jp); setBounds(120, 160, 550, 200); this.validate(); } //统计部门工资 else if (e.getSource() == item19) { this.getContentPane().removeAll(); jp = new JPanel(); jj19 = new JButton("ok"); jt19 = new JTextField(16); jp.setLayout(new FlowLayout()); jp.add(jj19); jp.add(jt19); jj19.addActionListener(this); this.setLayout(new BorderLayout()); this.add(jp, BorderLayout.NORTH); // this.setBounds(10,10,550,200); this.setVisible(true); this.validate(); this.setBounds(10, 10, 550, 203); } //统计总厂工资(没有这个功能了)
// else if (e.getSource() == item20) {
// this.getContentPane().removeAll();
// jp = new JPanel();
// try {
// con = getConnection();
//// sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
// ResultSet.CONCUR_READ_ONLY);
// rs = sql.executeQuery("SELECT * FROM CalEmpAndDep");
// rs.last();
// int k = rs.getRow();
// a20 = new Object[k + 1][2];
// rs.beforeFirst();
// k = 0;
// double sum = 0;
// while (rs.next()) {
// a20[k][0] = rs.getDouble(1);
// a20[k][1] = rs.getInt(2);
// sum = sum + rs.getDouble(1);
// // System.out.println(a20[k][0]+""+a20[k][1]);
// k++;
// }
// a20[k][0] = sum;
// a20[k][1] = "厂总工资";
// con.close();
// } catch (SQLException e1) {
// e1.printStackTrace();
// }
// jp.setLayout(new BorderLayout());
// table20 = new JTable(a20, name20);
// jp.add(new JScrollPane(table20), BorderLayout.CENTER);
// this.add(jp);
// this.validate();
// }
//删除职工信息
else if (e.getSource() == item21) {
this.getContentPane().removeAll();
jp = new JPanel();
hintLabel21 = new JLabel("输入员工编号:");
jb21 = new JButton("删除记录");
inputNumber21 = new JTextField(16);
jp.add(hintLabel21);
jp.add(inputNumber21);
jp.add(jb21);
this.add(jp);
inputNumber21.addActionListener(this);
jb21.addActionListener(this);
setBounds(20, 60, 700, 200);
this.validate();
}
//删除职工出勤信息
else if (e.getSource() == item22) {
this.getContentPane().removeAll();
jj22 = new JButton("ok");
jt22 = new JTextField(16);
jp = new JPanel();
jp.setLayout(new FlowLayout());
jp.add(jt22);
jp.add(jj22);
jj22.addActionListener(this);
jl22 = new JTextField(16);
jb22 = new JButton("删除");
jb22.addActionListener(this);
JPanel jpj = new JPanel();
jpj.setLayout(new FlowLayout());
jpj.add(jl22);
jpj.add(jb22);
this.add(jpj, BorderLayout.NORTH);
this.add(jp, BorderLayout.SOUTH);
this.setBounds(12, 10, 500, 500);
this.setVisible(true);
this.validate();
}
//删除职工津贴信息
else if (e.getSource() == item23) {
this.getContentPane().removeAll();
jj23 = new JButton("ok");
jt23 = new JTextField(16);
jp = new JPanel();
jp.setLayout(new FlowLayout());
jp.add(jt23);
jp.add(jj23);
jj23.addActionListener(this);
jl23 = new JTextField(16);
jb23 = new JButton("删除");
jb23.addActionListener(this);
JPanel jpj = new JPanel();
jpj.setLayout(new FlowLayout());
;
jpj.add(jl23);
jpj.add(jb23);
this.add(jpj, BorderLayout.NORTH);
this.add(jp, BorderLayout.SOUTH);
this.setBounds(12, 10, 500, 500);
this.setVisible(true);
this.validate();
}//修改职工部门监听 if (e.getSource() == inputNumber) { try { num = inputNumber.getText().trim(); con = getConnection(); sql = con.createStatement(); rs = sql.executeQuery("SELECT * FROM DepAndEmp WHERE dep_empEmpNo='" + num + "'"); boolean boo = rs.next(); if (boo == false) { JOptionPane.showMessageDialog(this, "该员工不存在", "提示", JOptionPane.WARNING_MESSAGE); } else { a[0][0] = rs.getInt(2); table.repaint(); } con.close(); } catch (SQLException ee) { System.out.println(ee); } } if (e.getSource() == enterModify) { try { con = getConnection(); sql = con.createStatement(); sql.executeUpdate("UPDATE DepAndEmp SET dep_empDepNo=" + a[0][0] + " WHERE dep_empEmpNo='" + num + "'"); JOptionPane.showMessageDialog(this, "修改成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "修改失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } // 修改职工基本工资监听 if (e.getSource() == inputNumber3) { try { num = inputNumber3.getText().trim(); con = getConnection(); sql = con.createStatement(); rs = sql.executeQuery("SELECT * FROM EmpAndSal WHERE emp_salEmpNO='" + num + "'"); boolean boo = rs.next(); if (boo == false) { JOptionPane.showMessageDialog(this, "该员工不存在", "提示", JOptionPane.WARNING_MESSAGE); } else { a3[0][0] = rs.getInt(2); a3[0][1] = rs.getInt(3); table3.repaint(); } con.close(); } catch (SQLException ee) { System.out.println(ee); } } if (e.getSource() == enterModify3) { try { con = getConnection(); sql = con.createStatement(); sql.executeUpdate("UPDATE EmpAndSal SET emp_salTimeLev=" + a3[0][0] + ",emp_salTechLev=" + a3[0][1] + " WHERE emp_salEmpNO='" + num + "'"); JOptionPane.showMessageDialog(this, "修改成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "修改失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } // 修改出勤表信息监听 if (e.getSource() == inputnum4) { try { int x = Integer.parseInt(inputnum4.getText().trim()); num = inputnum4.getText().trim(); con = getConnection(); sql = con.createStatement(); rs = sql.executeQuery("SELECT * from presence where pre_no=" + x); boolean boo = rs.next(); if (boo == false) { JOptionPane.showMessageDialog(this, "出勤类别号不存在", "提示", JOptionPane.WARNING_MESSAGE); } else { a4[0][0] = rs.getString(2); a4[0][1] = rs.getDouble(3); table4.repaint(); } con.close(); } catch (SQLException ee) { System.out.println(ee); } } if (e.getSource() == enter4) { try { con = getConnection(); //System.out.println(a4[0][0] + "," + a4[0][1] + "," + num); sql = con.createStatement(); int k = sql.executeUpdate("update presence set pre_name='" + a4[0][0] + "',pre_xishu=" + Double.parseDouble(a4[0][1].toString()) + " where pre_no='" + num + "'"); if (k == 1) { JOptionPane.showMessageDialog(this, "信息更新成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "更新失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } // 监听修改津贴信息 if (e.getSource() == inputnum5) { int k = Integer.parseInt(inputnum5.getText().trim()); try { System.out.println(k + ""); con = getConnection(); sql = con.createStatement(); rs = sql.executeQuery("SELECT * from Jintie where jin_no=" + k); boolean boo = rs.next(); if (boo == false) { JOptionPane.showMessageDialog(this, "出勤类别号不存在", "提示", JOptionPane.WARNING_MESSAGE); } else { a5[0][0] = rs.getString(2); a5[0][1] = rs.getDouble(3); table5.repaint(); } // System.out.println(Double.parseDouble(a5[0][1].toString())+""); con.close(); } catch (SQLException ee) { System.out.println(ee); } } if (e.getSource() == enter5) { int k = Integer.parseInt(inputnum5.getText().trim()); try { con = getConnection(); sql = con.createStatement(); // System.out.println(Double.parseDouble(a5[0][1].toString())+""); int m = sql.executeUpdate("update jintie set jin_name='" + a5[0][0] + "',jin_Money=" + Double.parseDouble(a5[0][1].toString()) + " where jin_no='" + k + "'"); if (m == 1) { JOptionPane.showMessageDialog(this, "信息修改成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "修改失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } // 修改工资工龄监听 if (e.getSource() == inputnum6) { int k = Integer.parseInt(inputnum6.getText().trim()); try { // System.out.println(k+""); con = getConnection(); sql = con.createStatement(); rs = sql.executeQuery("SELECT * from SalAndTime where sal_timeLev=" + k); boolean boo = rs.next(); if (boo == false) { JOptionPane.showMessageDialog(this, "该等级不存在", "提示", JOptionPane.WARNING_MESSAGE); } else { a6[0][0] = rs.getDouble(2); table6.repaint(); } con.close(); } catch (SQLException ee) { System.out.println(ee); } } if (e.getSource() == enter6) { int k = Integer.parseInt(inputnum6.getText().trim()); try { con = getConnection(); sql = con.createStatement(); int m = sql .executeUpdate("update SalAndTime set sal_timeMoney=" + Double.parseDouble(a6[0][0].toString()) + " where sal_timeLev='" + k + "'"); if (m == 1) { JOptionPane.showMessageDialog(this, "信息修改成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "修改失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } // 修改职务工资监听 if (e.getSource() == inputnum7) { int k = Integer.parseInt(inputnum7.getText().trim()); try { // System.out.println(k+""); con = getConnection(); sql = con.createStatement(); rs = sql.executeQuery("SELECT * from SalAndTech where sal_techLev=" + k); boolean boo = rs.next(); if (boo == false) { JOptionPane.showMessageDialog(this, "该等级不存在", "提示", JOptionPane.WARNING_MESSAGE); } else { a7[0][0] = rs.getDouble(2); table7.repaint(); } con.close(); } catch (SQLException ee) { System.out.println(ee); } } if (e.getSource() == enter7) { int k = Integer.parseInt(inputnum7.getText().trim()); try { con = getConnection(); sql = con.createStatement(); int m = sql .executeUpdate("update SalAndTech set sal_techMoney=" + Double.parseDouble(a7[0][0].toString()) + " where sal_techLev='" + k + "'"); if (m == 1) { JOptionPane.showMessageDialog(this, "信息修改成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "修改失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } // 添加职工信息监听 if (e.getSource() == enterInsert8) { try { con = getConnection(); con.setAutoCommit(false); sql = con.createStatement(); int k = sql.executeUpdate("INSERT INTO employees VALUES('" + a8[0][0] + "','" + a8[0][1] + "','" + a8[0][2] + "','" + a8[0][3] + "','" + a8[0][4] + "','" + a8[0][5] + "','" + a8[0][6] + "','" + a8[0][7] + "','" + a8[0][8] + "')"); System.out.println("k = " + k); int m = sql .executeUpdate("INSERT INTO EmpandSal(emp_salEmpNO,emp_salTimeLev,emp_salTechLev) VALUES('" + a8[0][0] + "'," + a8[0][8] + "," + a8[0][10] + ")"); int n = sql.executeUpdate("INSERT INTO DepAndEmp VALUES('" + a8[0][0] + "'," + a8[0][9] + ")"); int l = sql .executeUpdate("INSERT INTO EmpAndRSal(emp_rsalEmpNo) VALUES('" + a8[0][0] + "')"); if (k == 1 && m == 1 && n == 1 && l == 1) JOptionPane.showMessageDialog(this, "插入成功", "成功", JOptionPane.PLAIN_MESSAGE); con.commit(); con.close(); } catch (SQLException ee) { try { con.rollback(); JOptionPane.showMessageDialog(this, "插入失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } catch (SQLException e1) { e1.printStackTrace(); } } } // 添加出勤信息监听 if (e.getSource() == enterInsert9) { try { con = getConnection(); sql = con.createStatement(); int k = sql.executeUpdate("INSERT INTO EmpAndPre VALUES('" + a9[0][0] + "'," + a9[0][1] + "," + a9[0][2] + ")"); if (k == 1) JOptionPane.showMessageDialog(this, "插入成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "插入失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } //添加津贴信息监听 if (e.getSource() == enterInsert10) { try { con = getConnection(); sql = con.createStatement(); int k = sql.executeUpdate("INSERT INTO EmpAndJintie VALUES('" + a10[0][0] + "'," + a10[0][1] + ")"); if (k == 1) JOptionPane.showMessageDialog(this, "插入成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "插入失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } // 添加出勤信息监听 if (e.getSource() == enterInsert11) { try { con = getConnection(); sql = con.createStatement(); int k = sql.executeUpdate("INSERT INTO Presence VALUES(" + Integer.parseInt(a11[0][0].toString()) + ",'"+ a11[0][1] + "',"+ Double.parseDouble(a11[0][2].toString()) + ")"); if (k == 1) JOptionPane.showMessageDialog(this, "插入成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "插入失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } // 添加津贴信息监听 if (e.getSource() == enterInsert12) { try { con = getConnection(); sql = con.createStatement(); int k = sql.executeUpdate("INSERT INTO Jintie VALUES(" + Integer.parseInt(a12[0][0].toString()) + ",'" + a12[0][1] + "'," + Double.parseDouble(a12[0][2].toString()) + ")"); if (k == 1) JOptionPane.showMessageDialog(this, "插入成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "插入失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } // 添加工龄等级监听 if (e.getSource() == enterInsert13) { try { con = getConnection(); // con = DriverManager.getConnection("jdbc:odbc:guo", "system", // "system"); cstmt = con.prepareCall("{ call insert_data(?,?,?,?,?) }"); cstmt.setInt(1, 1); cstmt.setInt(2, 0); cstmt.setInt(3, Integer.parseInt(a13[0][0].toString())); System.out.println("here:" + Double.parseDouble(a13[0][0].toString()) + ""); cstmt.setDouble(4, Double.parseDouble(a13[0][1].toString())); cstmt.registerOutParameter(5, java.sql.Types.DECIMAL); cstmt.execute(); int k = cstmt.getInt(5); System.out.println(cstmt.getInt(5)); // sql=con.createStatement(); // int // k=sql.executeUpdate("INSERT INTO SalAndTime VALUES("+Integer.parseInt(a13[0][0].toString())+","+Double.parseDouble(a13[0][1].toString())+")"); if (k == 0) JOptionPane.showMessageDialog(this, "插入成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "插入失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } // 添加职务工资信息监听 if (e.getSource() == enterInsert14) { try { con = getConnection(); cstmt = con.prepareCall("{ call insert_data(?,?,?,?,?) }"); cstmt.setInt(1, 0); cstmt.setInt(2, 1); cstmt.setInt(3, Integer.parseInt(a14[0][0].toString())); cstmt.setDouble(4, Double.parseDouble(a14[0][1].toString())); cstmt.registerOutParameter(5, java.sql.Types.DECIMAL); cstmt.execute(); int k = cstmt.getInt(5); System.out.println(cstmt.getInt(5)); // sql=con.createStatement(); // int // k=sql.executeUpdate("INSERT INTO SalAndTech VALUES("+Integer.parseInt(a14[0][0].toString())+","+Double.parseDouble(a14[0][1].toString())+")"); if (k == 0) JOptionPane.showMessageDialog(this, "插入成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "插入失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } // 监听部门工资统计 if (e.getSource() == jj19) { int m = Integer.parseInt(jt19.getText().toString()); System.out.println("m = " + m); try { con = getConnection(); sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = sql.executeQuery("SELECT emp_rsalEmpNo,emp_rsalary FROM DepAndEmp,EmpAndRSal WHERE dep_empEmpNo=emp_rsalEmpNo AND dep_empDepNo=" + m); rs.last(); int k = rs.getRow(); if (k != 1) { a19 = new Object[k + 1][2]; rs.beforeFirst(); k = 0; double sum = 0; while (rs.next()) { a19[k][0] = rs.getString(1); a19[k][1] = rs.getDouble(2); sum = sum + rs.getDouble(2); // System.out.println(a[k][0]+""+a[k][1]); k++; } a19[k][0] = "该部门总工资"; a19[k][1] = sum; con.close(); table19 = new JTable(a19, name19); add(new JScrollPane(table19), BorderLayout.CENTER); } else JOptionPane.showMessageDialog(this, "输入错误", "错误", JOptionPane.ERROR_MESSAGE); } catch (SQLException e1) { e1.printStackTrace(); } table19 = new JTable(a19, name19); add(new JScrollPane(table19), BorderLayout.CENTER); validate(); } // 删除职工信息监听 if (e.getSource() == jb21) { try { con = getConnection(); sql = con.createStatement(); int l = sql .executeUpdate("delete from employees where emp_No='" + inputNumber21.getText() + "'"); if (l == 1) JOptionPane.showMessageDialog(this, "删除成功", "成功", JOptionPane.PLAIN_MESSAGE); else JOptionPane.showMessageDialog(this, "没有该员工", "警告", JOptionPane.WARNING_MESSAGE); con.close(); } catch (SQLException ee) { JOptionPane.showMessageDialog(this, "删除失败" + ee, "失败", JOptionPane.ERROR_MESSAGE); } } // 删除员工出勤信息监听 if (e.getSource() == jj22) { num = jt22.getText(); try { con = getConnection(); sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = sql.executeQuery("SELECT * FROM EmpAndPre WHERE emp_preEmpNo='" + num + "'"); rs.last(); int k = rs.getRow(); a22 = new Object[k][3]; rs.beforeFirst(); k = 0; while (rs.next()) { a22[k][0] = rs.getString(1); a22[k][1] = rs.getInt(2); a22[k][2] = rs.getInt(3); k++; } con.close(); } catch (SQLException e1) { e1.printStackTrace(); } table22 = new JTable(a22, name22); add(new JScrollPane(table22), BorderLayout.CENTER); JPanel jpj = new JPanel(); jpj.setLayout(new FlowLayout()); validate(); } else if (e.getSource() == jb22) { String b = jt22.getText(); int c = Integer.parseInt(jl22.getText()); System.out.println(b + " " + c); try { con = getConnection(); sql = con.createStatement(); int l = sql .executeUpdate("DELETE FROM EmpAndPre WHERE emp_preEmpNo='" + b + "' and emp_prePreNo=" + c + ""); if (l == 0) { JOptionPane.showMessageDialog(this, "删除失败", "失败", JOptionPane.ERROR_MESSAGE); } else JOptionPane.showMessageDialog(this, "删除成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } catch (SQLException e1) { e1.printStackTrace(); } validate(); } //删除职工津贴信息 if (e.getSource() == jj23) { num = jt23.getText(); try { con = getConnection(); sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = sql.executeQuery("SELECT * FROM EmpAndJintie WHERE emp_jinEmpNo='" + num + "'"); rs.last(); int k = rs.getRow(); a23 = new Object[k][2]; rs.beforeFirst(); k = 0; while (rs.next()) { a23[k][0] = rs.getString(1); a23[k][1] = rs.getInt(2); k++; } con.close(); } catch (SQLException e1) { e1.printStackTrace(); } table23 = new JTable(a23, name23); add(new JScrollPane(table23), BorderLayout.CENTER); JPanel jpj = new JPanel(); jpj.setLayout(new FlowLayout()); validate(); } else if (e.getSource() == jb23) { String b = jt23.getText(); int c = Integer.parseInt(jl23.getText()); System.out.println(b + " " + c); try { con = getConnection(); sql = con.createStatement(); int l = sql .executeUpdate("DELETE FROM EmpAndJintie WHERE emp_jinEmpNo='" + b + "' and emp_jinJinNo=" + c + ""); if (l == 0) { JOptionPane.showMessageDialog(this, "删除失败", "失败", JOptionPane.ERROR_MESSAGE); } else JOptionPane.showMessageDialog(this, "删除成功", "成功", JOptionPane.PLAIN_MESSAGE); con.close(); } catch (SQLException e1) { e1.printStackTrace(); } } } private Connection getConnection() {// String url = "jdbc:sqlserver://localhost:1433;DatabaseName=Salary"; try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");//加载mysql的驱动 return (Connection) DriverManager.getConnection(url, "sa", "123"); //返回数据库的连接 } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return null; } public static void main(String args[]) { new adminUser(); }
}
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at ch12.adminUser.actionPerformed(adminUser.java:1201)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
解决方案
java.lang.NullPointerException空指针异常;这代表你哪个变量或方法传值没有传到,里面是空的。
你可以用System.out.println将各个变量或者带回值得方法打印一下,看看哪个是空的,然后就知道哪里是空的,接着在这个地方找找问题解决掉就可以了
如果回答对你有帮助,请采纳
解决方案二:
ch12.adminUser.actionPerformed(adminUser.java:1201),这个anction第1201行,调试一下,里面有null对象
解决方案三:
adminUser.java类里面的actionPerformed方法里面出现了空指针
解决方案四:
java.lang.NullPointerException指针异常,在第1201行有指针错误,你可以在那里多检查一下,建议楼主先学习一些系统的视频再写代码,这样思路更清晰
解决方案五:
ch12.adminUser中1201行有问题,你最好把代码贴出来看下,或者自己调试跟一下。
解决方案六:
ch12.adminUser.actionPerformed(adminUser.java:1201),此action所使用的
解决方案七:
at ch12.adminUser.actionPerformed(adminUser.java:1201) 这个里面有问题,用debug试试是什么原因造成的。
解决方案八:
把代码贴出来比较有针对性
解决方案九:
这个异常应该算是最简单的一个异常了。很简单的方法,首先找到发生异常的那行,然后寻找逐步向上找源头。如果没有必要查找源头,可以直接绕过它。譬如:1.List books = BooKDAO.findAll();2.int size = books.size();如果第2行发生空指针异常了,知道books肯定为null了,这时查找BookDAO.的findAll方法,如果findAll()方法又调用了其他的方法,可以继续查下去。如果没有业务需要,可以直接写成:List books = BooKDAO.findAll();int size = 0;if(books != null){size = books.size();}或者List books = BooKDAO.findAll();int size = 0;try{size = books.size();}catch(NullpointerException){size = 0;或者不写或者打印错误}
解决方案十:
貌似是最常见一种异常吧,,空指针异常。