Question

import java.sql.*; public class DDTest4 ( public static void main(String[] args) throws Exception( String urijdba:mysql://localhost:3306/CarShop"; String user - "root" string pass="root"; Connection con DriverManager.getConnection( user,pass): Statement stcon.createStatement (); PreparedStatement psticon.preparestatement("select from

product where pid=?"); PreparedStatement pst2 con.preparestatement ( "insert into product (pid, name, company,price, quantity) values (?,?,?.?.?)"); psti. 1, 2): Resultset rs psti. while (rs.next()) { System.out.println (rs.getString("name")+""+rs.getDouble ("price")); ) pst2.setInt (1,3): (2,"LS350"): pst2.setstring (3, "Lexus"); (4,15600.0); pst2 pst2. pst2.setInt (5,7): int rows pst2.executeUpdate(): pst2.setInt (1,4): pst2.setString (2,"1525"); pst2.setString (3,"BMW"): pst2.setDouble (4,18200.0): pst2.setInt (5,6): rows pst2. pst1.setInt (1, 4); Es psti.executeQuery(): while (rs.next()) { System.out.printin (rs.getString("name") + "+rs.getString ("company")+""+rs.getDouble ("price")); } pst1.setInt (1, 1); rs psti.executeQuery(): while (rs.next()) { System.out.println (rs. 1 1 1 pstl.setInt (1, 3): rs psti.executeQuery(): while (rs.next()) { System.out.println(rs.getString ("name")+""+rs.getDouble ("price")); "name") "+rs.getDouble ("price")); st.close(): psti.close(); pst2.close(); zows - st. ("delete from product where pid>2"); rows - st.executeUpdate("update product set price 4500.0 where pid-2") ;

Fig: 1

Fig: 2