JDBC Crud Operation Delete Multiple Records With Prepared Statement in Java

 package jdbc_pre_stmt;


import java.sql.Connection;

import java.sql.DriverManager;

import com.mysql.jdbc.PreparedStatement;


public class Jdbc_Pre_Stmt_Delete {

public static void main(String[] args) throws Exception{

Class.forName("com.mysql.jdbc.Driver");

System.out.println("Driver Loaded......");

Connection cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/batch138","root","root");

System.out.println("Connection Success.....");

PreparedStatement ps=(PreparedStatement) cn.prepareStatement("delete from student where id=?");

ps.setInt(1, 1010);

ps.execute();

ps.setInt(1, 1);

ps.execute();

ps.setInt(1, 10);

ps.execute();

}

}

Comments

Popular posts from this blog

Primary/Main features of Java

HTTrack ऑफलाइन वेबसाइट डाउनलोडर क्या है ?

Which language is used for Java?