标签:mamicode root void ext imp statement src otf driver
import java.sql.*; public class DBUtil { public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.cj.jdbc.Driver"); Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/imooc", "root", "123"); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery("select user_name, age from imooc_gaddess"); while (resultSet.next()){ System.out.println(resultSet.getString("user_name") + "年龄:" + resultSet.getInt("age")); } } }
标签:mamicode root void ext imp statement src otf driver
原文地址:https://www.cnblogs.com/yanguobin/p/12005685.html