package cn.sasa.demo3;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;
public class JDBCDemo3 {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
double price = 0;
int pid = 0;
Scanner sc = new Scanner(System.in);
System.out.println("price");
price = sc.nextDouble();
System.out.println("pid");
pid = sc.nextInt();
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://192.168.0.207:3306/mydb", "root", "XXXXXXXXXXXXXX1");
String sql = "UPDATE product SET price=? WHERE pid=?;";
PreparedStatement pstate = conn.prepareStatement(sql);
pstate.setObject(1, price);
pstate.setObject(2, pid);
int rows = pstate.executeUpdate();
System.out.println(rows);
pstate.close();
conn.close();
}
}