@FXML
private void ekle() throws Exception{
try{
Connection conn2 = dc.getConnection();
pst=conn2.prepareStatement(query_ekle);
pst.setString(1, text_no.getText());
pst.setString(2, text_stok.getText());
pst.setString(3, text_tarih.getText());
pst.setString(4, text_garanti.getText());
pst.setString(5, text_marka.getText());
pst.setString(6, text_model.getText());
pst.setString(7, text_aile.getText());
pst.setString(8, text_hiz.getText());
pst.setString(9, text_bellek.getText());
pst.setString(10, text_cekirdek.getText());
pst.setString(11, text_soket.getText());
pst.setString(12, text_watt.getText());
pst.setString(13, text_ie.getText());
pst.setString(14, text_ug.getText());
pst.execute();
pst.close();
} catch(Exception e){
System.out.println(e);
}
}
////////////////////////////////////////////////////////////////////
private connect dc = new connect();
Connection conn3;
PreparedStatement pst=null;
////////////////////////////////////////////////////////////////
String query_ekle="INSERT INTO urunler(u_no,u_stok_miktari,u_alindigi_tarih,u_garanti_suresi,u_marka,u_modeli,u_ailesi,"
+ "u_hizi,u_bellek,u_cekirdek,u_soket,u_watt,ie_no,ug_no) Values('?','?','?','?','?','?','?','?','?','?','?','?','?','?')";
///////////////////////////////////////////////////////////////////
public class connect {
private String url="jdbc:mysql://localhost:3306/";
private String dbAdi="my_database1";
private String userAdi="root";
private String userPass="14907";
public Connection getConnection() throws Exception{
try{
Class.forName("com.mysql.jdbc.Driver");
Connection connection=(Connection) DriverManager.getConnection(url+dbAdi,userAdi,userPass);
return connection;
}catch(Exception e){
System.out.println(e);
}
return null;
}
}
////////////////////////////////////////////////////////
Asked
Active
Viewed 24 times
1

Keiwan
- 8,031
- 5
- 36
- 49

serdar oztufekci
- 59
- 8
-
Welcome to Stack Overflow. I recommend you read some of the help pages on [asking questions](http://stackoverflow.com/help/on-topic); in particular note *'Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself.'* In particular, in this case you should post the complete [stack trace](http://stackoverflow.com/q/3988788/2775450), identify the line in the code you posted that throws the exception, and show why you think the relevant reference is not null. – James_D Dec 15 '16 at 22:12
-
And the error only this line: java.lang.NullPointerException – serdar oztufekci Dec 15 '16 at 22:23
-
@serdaröztüfekçi Then stop catching the exception and ignore it. At the very least, use `e.printStackTrace(System.out);` instead of `System.out.println(e);`, but you should really **not** continue execution as if nothing went wrong. – Andreas Dec 15 '16 at 22:31
-
Again, please post the complete [stack trace](http://stackoverflow.com/q/3988788/2775450). (If you don't know what a stack trace is, please read the linked question.) No-one can possibly help unless you give them the relevant information. – James_D Dec 15 '16 at 22:31
-
ı use "e.printStackTrace(System.out);" and i take a very long error. but all errors in (method,events,node etc.) java's dafault class. no error in my any class – serdar oztufekci Dec 15 '16 at 22:36