@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;
}
}
////////////////////////////////////////////////////////