import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class Jdbc {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
//zhucequdong
Class.forName("com.mysql.jdbc.Driver");
//huoqulianjieduix
Connection conne = DriverManager.getConnection("jdbc:mysql://localhost:3306/db1", "root", "root");
//dingyisqlyuju
String sql = "update account set balance=500 where id =1";
Statement stmt = conne.createStatement();
int count = stmt.executeUpdate(sql);
System.out.println(count);
stmt.close();
conne.close();
}
}
JDBC连接MySQL数据库
最新推荐文章于 2024-02-04 11:08:02 发布