자바의 SQL Server에 레코드를 추가하려고합니다. 먼저 Connection 오브젝트를 생성 할 필요java.lang.NullPointerException ** 오류?
public class DB {
Connection con = null;
Statement stmt Nnull ;
component cmp = new Component();
public long pSave(Component cmp) {
String i = cmp.getI();
String s = cmp.getS();
String a = cmp.getA();
int t = cmp.getT();
int c = cmp.getC();
System.out.println("1");
try {
System.out.println("2");
stmt = con.createStatement();
System.out.println("3");
String SQL =
"INSERT INTO kisi (cl1,cl2,cl3,cl4,cl5) "
+ "VALUES(" + i + "," + s + "," + a + "," + c + "," + t + ")";
System.out.println("4");
stmt.executeUpdate(SQL);
System.out.println("Success");
return 1;
} catch(Exception e) {
System.out.println("Error " + e);
return 0;
}
}
}
당신은 당신이 문을 초기화하는 때 당신이 호출 연결 ('사기')을 초기화 didnt가 .. ('STMT = con.createstatement를') – Rob
전체 스택 추적을 수행 하시겠습니까? 예외 메시지를 인쇄하지 마십시오. 실제로 진행중인 작업을 숨길 수 있습니다. 이 목적을 위해, e.printStackTrace() – pcalcao