Skip to main content

The value is not set for the parameter number 1.

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
zhr_
Offline
Joined: 2014-07-20

?t's hospital project.I want to insert values that is in jtextbox to database.But I have error.Is there anyone help me

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=Hastane;user=Test;password=Sz04022010;");
String sql="insert into dbo.tbl_personel(AdSoyad,TC,UnvanID,SicilNo,Email,DogumTarihi,DogumYeri,DiplomaNo,Telefon,Adres) VALUES(?,?,?,?,?,?,?,?,?,?)";
PreparedStatement prepared=con.prepareStatement(sql);

prepared.executeUpdate();

prepared.setString(1,jTextField6.getText());
prepared.setString(2,jTextField3.getText());
prepared.setInt(3,Integer.parseInt(jTextField5.getText()));
prepared.setString(4,jTextField2.getText());
prepared.setString(5,jTextField8.getText());
prepared.setString(6,jTextField9.getText());
prepared.setString(7,jTextField10.getText());
prepared.setString(8,jTextField7.getText());
prepared.setString(9,jTextField4.getText());
prepared.setString(10,jTextArea1+jTextArea2.getText());
JOptionPane.showMessageDialog(rootPane,"Kay?t Eklendi");
} catch (SQLException | ClassNotFoundException ex) {
Logger.getLogger(Personel.class.getName()).log(Level.SEVERE, null, ex);
}

}