samedi 31 mai 2014

TranslateApiException: The Azure Market Place Translator Subscription associated with the request credentials has zero balance. : ID=1446.V2_Json.Translate.4B9E8D38


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)     
{

Connection conn=DbCon.conDB();
//String Mname =jComboBox1.getSelectedItem().toString();
String sql="delete Name from nowshowingmovie where Name = '"+jComboBox1.getSelectedItem().toString()+"'";
try{

pst=conn.prepareStatement(sql);
// pst.executeQuery();
pst.executeUpdate(sql);
JOptionPane.showMessageDialog(null,"Movie Deleted Sucessfully");
}

catch(SQLException e)
{
JOptionPane.showMessageDialog(null, e);
}

}



2 issues:



  1. In general the syntax for DELETE is

    String sql = "delete from nowshowingmovie where Name = '"+jComboBox1.getSelectedItem().toString()+"'";


  2. PreparedStatement doesn't use the SQL String, i.e. just use pst.executeUpdate()



Side note: Since you're already using a PreparedStatement you can use a placeholder to avoid SQL injection attacks


String sql = "delete from nowshowingmovie where Name = ?";
pst.setString(1, jComboBox1.getSelectedItem().toString());
pst.executeUpdate();


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)     
{

Connection conn=DbCon.conDB();
//String Mname =jComboBox1.getSelectedItem().toString();
String sql="delete Name from nowshowingmovie where Name = '"+jComboBox1.getSelectedItem().toString()+"'";
try{

pst=conn.prepareStatement(sql);
// pst.executeQuery();
pst.executeUpdate(sql);
JOptionPane.showMessageDialog(null,"Movie Deleted Sucessfully");
}

catch(SQLException e)
{
JOptionPane.showMessageDialog(null, e);
}

}


2 issues:



  1. In general the syntax for DELETE is

    String sql = "delete from nowshowingmovie where Name = '"+jComboBox1.getSelectedItem().toString()+"'";


  2. PreparedStatement doesn't use the SQL String, i.e. just use pst.executeUpdate()



Side note: Since you're already using a PreparedStatement you can use a placeholder to avoid SQL injection attacks


String sql = "delete from nowshowingmovie where Name = ?";
pst.setString(1, jComboBox1.getSelectedItem().toString());
pst.executeUpdate();

Related Posts:

0 commentaires:

Enregistrer un commentaire