JDBC Crud Operation Update 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_Update {

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("update student set name=? where id=?");

ps.setString(1, "Pune");

ps.setInt(2, 3010);

ps.execute();

ps.setString(1, "Python");

ps.setInt(2, 102);

ps.execute();

ps.setString(1, "Acer");

ps.setInt(2, 1010);

ps.execute();

}


}

Comments

Popular posts from this blog

Primary/Main features of Java

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

Which language is used for Java?