What are the codes when you cancel a list of names in the database in a certain field?
This is the situation:
I made a reservation in a certain hotel. Of course they asked my name, what kind of room. . Automatically, it saved on the database of their system. But suddenly, i changed my mind. . I made a cancellation on my reservation I made. .
In java program what are the codes necessary to cancel if the database is connected that needs automatic cancellation in the system???
Please help. . I'm just a beginner. . Thanks!
I'm not so sure of my codes:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class database
{
public static void main(String [] args)
{
int d=0;
int ans=1;
String msg;
do
{
int select = 0;
String select0 = JOptionPane.showInputDialog("Enter Customer Name ");
//select = Integer.parseInt(select0);
if(select == 1)
{
if(d==0)
{
Delete sweetie = new Delete();
d++;
}
}
}
while(ans==1);
}}
/////////////////////////////////////////////////
import java.sql.*;
import javax.swing.*;
public class Cancel
{
public Cancel()
{
String msg1=JOptionPane.showInputDialog("Enter name: " );
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:trial","test","database");
Statement stmt = conn.createStatement();
String query;
try
{
JOptionPane.showMessageDialog(null, "Cancel Customer Reservation");
PreparedStatement jane = conn.prepareStatement("CANCEL * FROM RESERVATION WHERE name = (?) ");
jane.setString(1,msg1);
jane.executeUpdate();
JOptionPane.showMessageDialog(null,"Cancellation successful!");
jane.close();
stmt.close();
conn.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
catch (ClassNotFoundException cnfex)
{
System.err.println("Failed to load JDBC/ODBC driver");
cnfex.printStackTrace();
System.exit(1);
}
catch(SQLException sqlex)
{
System.err.println(sqlex);
sqlex.printStackTrace();
}
}
}