package com.dxm;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import com.sun.java_cup.internal.runtime.Scanner;
public class JDBCDemo3 {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
// TODO Auto-generated method stub
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/mybase";
String user="root";
String password="1234";
Connection connection = DriverManager.getConnection(url, user, password);
String sql = "update sort set sname=?,sprice=? where sid=?";
PreparedStatement statement = connection.prepareStatement(sql);
statement.setObject(1, "汽车美容");
statement.setObject(2, "4500");
statement.setObject(3, "7");
int i = statement.executeUpdate();
if (i>0) {
System.out.println("Update success");
}
statement.close();
connection.close();
}
}