Recent Posts

Monday, 12 November 2018

JDBC - Delete a Table

     This tutorial provides an example on how to delete a table using JDBC application.

Note
     Before going into the program, it is advised to go through JDBC Programming Basic Steps where the meaning of Connection, Statement etc. are discussed.
import java.sql.*;
/**
 * 
 * @author ashok.mariyala
 *
 */
public class DeleteTableDemo { 
   public static void main(String[] args) throws Exception {
      String sqlQuery = "drop table emp"; 
      Class.forName("oracle.jdbc.OracleDriver"); 
      Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","scott","tiger"); 
      Statement st = con.createStatement();
      st.executeUpdate(sqlQuery);
      System.out.println("Table Deleted Successfully");
      con.close();
   }
}

Next Tutorial : JDBC - Insert a record into table

Previous Tutorial : JDBC - Create a Table

No comments:

Post a Comment