Delete the record from DB Table

Here you will learn to delete record from a table using Java

/*
 * Here we will learn to delete the record from DB Table
 */
package jbt;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class DeleteRecordFromTable {
	public static void main(String[] args) throws SQLException,
			ClassNotFoundException {

		Class.forName("oracle.jdbc.OracleDriver");

		String serverName = "<server_name>";
		String portNumber = "1541";
		String sid = "";
		String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":"
				+ sid;
		String username = "<user_name>";
		String password = "";
		Connection conn = DriverManager.getConnection(url, username, password);

		Statement stmt = conn.createStatement();
		// ResultSet rs = stmt.executeQuery();
		int i = stmt.executeUpdate("delete from jbt_table where name ='JBT'");

		System.out.println("Number of record affected :" + i);

	}
}

 
fdsfffffdsffdfdssfsdfdfdfdsfs

Leave A Comment

Your email address will not be published. Required fields are marked *