Java Program to Delete a Column in a Table Using JDBC Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Before deleting a column in a table, first is need to connect the java application to the database. Java has its own API which JDBC API which uses JDBC drivers for database connections. Before JDBC, ODBC API was used but it was written in C which means it was platform-dependent. JDBC API provides the applications to JDBC connection and JDBC driver provides manager to driver connection. Algorithm: Always remember these 7 thumb golden steps to deal with JDBC in order to deal with the database and between App(Main) class and connection class of it. Importing the databaseRegistering the Java classEstablishing a connectionCreating a statementExecuting the queryProcess the resultsClosing connection Procedure: to delete a column in a table from the database created using JDBC is as follows: Step 1: Loading “mysqlconnector.jar” in the program. Step 2: Creating a database and adding a table with records Using MySQL'cmd' DriverDriverManager()Connection()Statement()Resultset() which the classes provided by JDBC APIFurther 5 steps are demonstrated in the java program. (App class or Main class) of the Connection class. Implementation: Java program using JDBC to delete a Column in a Table Java // Java program using JDBC to // Delete a Column in a Table // Step 1: Importing database files import java.sql.*; public class GFG { // URL that points to mysql database // DB stands for database static final String url = "jdbc:mysql://localhost:3306/db"; // Main driver method public static void main(String[] args) throws ClassNotFoundException { // Try block to check exceptions try { // Step 2: Load and Register drivers // Class.forName() method is user for // driver registration with name of the driver // as argument that used MySQL driver Class.forName("com.mysql.jdbc.Driver"); // Step 3: Create a connection // getConnection() establishes a connection // It takes url that points to your database // username and password of MySQL connections as // arguments Connection conn = DriverManager.getConnection( url, "root", "1234"); // create.Statement() creates statement object // which is responsible for executing queries on // table Statement stmt = conn.createStatement(); // Executing the query student is the table // name & address is column // Step 4: Create a statement String query = "ALTER TABLE student Drop address"; // Step 5: Execute the query // executeUpdate() returns number of rows // affected by the execution of the statement int result = stmt.executeUpdate(query); // Step 6: Process the results // if result is greater than 0 // it means values has been added if (result > 0) System.out.println( "A column from the table is deleted."); else System.out.println("unsuccessful deletion "); // Step 7: Closing connection conn.close(); } // Catch block to handle exceptions catch (SQLException e) { // Print the exception System.out.println(e); } } } Output: Comment More infoAdvertise with us Next Article Java Program to Use Methods of Column to Get Column Name in JDBC C chodankarsarvesha Follow Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 JDBC +1 More Practice Tags : Java Similar Reads Java Program to Insert Details in a Table using JDBC Java Database Connectivity is basically a standard API(application interface) between the java programming language and various databases like Oracle, SQL, Postgres, SQL, etc. It connects the front end(for interacting with the users ) with the backend( for storing data). Algorithm: Search/ Insert/ D 4 min read How to Get the Datatype of a Column of a Table using JDBC? Java supports many databases and for each database, we need to have their respective jar files to be placed in the build path to proceed for JDBC connectivity. MySQL: mysql-connector-java-8.0.22 or similar mysql connectors with different versions. In this article, we are using mysql-connector-java-8 5 min read Java Program to Search the Contents of a Table in JDBC In order to deal with JDBC standard 7 steps are supposed to be followed: Import the databaseLoad and register driversCreate a connectionCreate a statementExecute the queryProcess the resultsClose the connectionProcedure: Import the database-syntax  for importing the  sql database in java is- import 5 min read How to Perform a Cascading Delete Using JDBC? In JDBC, the Cascading Delete Operation is a technique of databases that are used to delete the record parent table. In this article, we will learn How to perform a cascading delete using JDBC. Cascading Delete Using JDBCTo Perform a Cascading Delete using JDBC (Java Database Connectivity), you need 2 min read Java Program to Use Methods of Column to Get Column Name in JDBC Java Database Connectivity or JDBC is a Java API (application programming interface) used to perform database operations through Java application. It allows the execution of SQL commands for the creation of tables and data manipulation through Java application. Java supports java.sql package which c 4 min read Java JDBC Programs - Basic to Advanced This article provides a variety of programs on JDBC, that are frequently asked in the technical round in various Software Engineering/JAVA Backend Developer Interviews including various operations such as CREATE, INSERT, UPDATE, DELETE and SELECT on SQL Database etc. Additionally, all programs come 3 min read Like