String name = tf1.getText();
b1.addActionListener( new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
try
{
Connection myConn = DriverManager.getConnection( "jdbc:mysql://localhost:3306/javaproject", "root", "noor1032" );
PreparedStatement myStat = myConn.prepareStatement( "DELETE FROM user_info WHERE username=?" );
myStat.setString( 1, name );
myStat.execute();
myConn.close();
JOptionPane.showMessageDialog( null, "deleted" );
}
catch ( Exception f )
{
System.out.println( f );
}
}
} );
有人能告诉我如何通过输入人名从MySQL代码中删除MySQL中的整行吗,一行包含其他值以及ID,年龄,体重等...但是我想删除仅基于名称。