数据库连接JDBC

1、创建数据库连接对象

Connection connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/database","root","12345");

2、创建Statement对象

Statement statement=connection.createStatement();

3、执行sql语句,返回ResultSet对象

ResultSet result=statement.executeQuery("select * from user");

4、关闭数据库连接

connection.close();

猜你喜欢

转载自www.cnblogs.com/jigang/p/12950869.html