Em đang tạo một project có chức năng tìm kiếm và chỉnh sửa thông tin kết nối dữ liệu postgreSQL và java. Trong quá trình chạy nó đã kết nối thành công nhưng đến đoạn thực hiện chính thì báo lỗi. Em mới tập tọe Java, mong mọi người giúp đỡ.
code:
Mã:
package info.company;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;

public class ClassMainDB {
	private static Connection c = null;
	private static ResultSet rs = null;
	static Scanner choise;
	static PreparedStatement prsCmd;
    String DB_CONNECTION;
    String DB_USER;
    String DB_PASS;
  //-----------------------------------------------------------------
    public ClassMainDB(String a,String b,String c) {
    	DB_CONNECTION=a;
    	DB_USER=b;
    	DB_PASS=c;
	}
    //----------------main------------------------------------
    
    public static void main(String args[]) throws SQLException {
		ClassMainDB db = new ClassMainDB("jdbc:postgresql://10.10.3.2:5432/dovanviet", "postgres","postgres");
		db.connectionDB();
		System.out.println("____________Welcome to MyCompany____________________");
		System.out.print("-----------------------------------------------------
");
		System.out.print("--(0) : Thoat chuong trinh
");
		System.out.print("--(1) : Search
");
		System.out.print("--(2) : Add user
");
		System.out.print("--(3) : Update user
");
		System.out.print("--(4) : Delete User
");
		System.out.print("-----------------------------------------------------
");
		db.preparedstatementDB();
		db.menuDB();
		db.closeDB();
	}
    
	// ---------------------------------connection------------------------------------------------------
	public void connectionDB() {
		try {
			Class.forName("org.postgresql.Driver");
			c = DriverManager.getConnection(
					DB_CONNECTION, DB_USER,
					DB_PASS);
			System.out.println("connected");
		} catch (Exception e) {
			System.err.println(e.getClass().getName() + ": " + e.getMessage());
			System.exit(0);
		}
	}
	// -----------------------------menu------------------------------------------------------------
	public void menuDB() throws SQLException {
		while (rs.next()) {
			int id = rs.getInt("id");
			String name = rs.getString("name");
			int age = rs.getInt("age");
			String address = rs.getString("address");
			String salary = rs.getString("salary");
			System.out.println("ID = " + id);
			System.out.println("NAME = " + name);
			System.out.println("AGE = " + age);
			System.out.println("ADDRESS = " + address);
			System.out.println("SALARY = " + salary);
			System.out.println();
		}
	}
	// ---------------------------------SELECT----------------------------------------------------------
	public void preparedstatementDB() throws SQLException {

		String preparedSQLsearch = "SELECT id,name,age,address,salary FROM company WHERE id=?;";
		String preparedSQLinsert = "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) VALUE(?)";
		String preparedSQLupdate = "UPDATE COMPANY set ? where ID=?";
		String preparedSQLdelete = "DELETE from COMPANY where ID=?";
		System.out.println("nhap lua chon :");
		int nhap = choise.nextInt();
		switch (nhap) {
		case 1:
			System.out.println("tim kiem thong tin user");
			prsCmd = c.prepareStatement(preparedSQLsearch);
			System.out.println("nhap id can tim : ");
			String id=choise.next();
			prsCmd.setString(1, id);
			break;
		case 2:
			System.out.println("them mot user");
			prsCmd = c.prepareStatement(preparedSQLinsert);
			System.out.println("nhap thong tin user moi the cu phap [id,'ten',tuoi,'que quan',luong]");
			String insertID=choise.next();
			prsCmd.setString(1, insertID);
			break;
		case 3:
			
			System.out.println("chinh sua thong tin user");
			prsCmd = c.prepareStatement(preparedSQLupdate);
			System.out.println("nhap id can chinh sua :");
			String id2=choise.next();
			System.out.println("nhap thong tin chinh sua :");
			String infofix=choise.next();
			prsCmd.setString(1, infofix);
			prsCmd.setString(2, id2);
			break;
		case 4:
			System.out.println("xoa mot user");
			prsCmd = c.prepareStatement(preparedSQLdelete);
			System.out.println("nhap id can xoa : ");
			String id3=choise.next();
			prsCmd.setString(1, id3);
			break;
		default:
			System.out.println("nhap sai");
		}
		rs = prsCmd.executeQuery();

	}
	// -----------------------------------CLOSE-------------------------------------------------------
	public void closeDB() throws SQLException {
		rs.close();
		prsCmd.close();
		c.close();
	}
}
và đây là Exception nó báo :
Mã:
Exception in thread "main" java.lang.NullPointerException
	at info.company.ClassMainDB.preparedstatementDB(ClassMainDB.java:79)
	at info.company.ClassMainDB.main(ClassMainDB.java:37)