已经完成数据库的连接
点击查看代码
package qixun;
import com.mysql.jdbc.Driver;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class jdbcDemo {
public static void main(String[] args) throws Exception{
//注册驱动
Class.forName("com.mysql.jdbc.Driver");
//获取连接
String url = "jdbc:mysql://localhost:3306/qiii?useSSL=false&serverTimezone=UTC";
String username = "root";
String password = "1234";
Connection conn=DriverManager.getConnection(url,username,password);
//定义
String sql="UPDATE ceeee set money = 6000 where id =2";
//获取执行
Statement stmt= conn.createStatement();
//执行
int count =stmt.executeUpdate(sql);//受影响的行数
//处理结果
System.out.println(count);
//释放
stmt.close();
conn.close();
}
}