package com.qf.jdbc;
// 数据库连接
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class Demo1 {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
// 加载驱动
Class.forName("com.mysql.jdbc.Driver");
// 创建和数据库连接
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3300/companydb?useUnicode=true&characterEncoding=UTF-8","root","1234");
Statement statement = conn.createStatement();
// 执行数据库操作
String sql = " update admin set phone='18921511258' where username= 'mike' ";
int i = statement.executeUpdate(sql);
if (i>0){
System.out.println("数据修改成功");
statement.close();
conn.close();
}
}
}