标签:etc jdbc sql tac str sele statement tor sel
1、需要mysql驱动包:mysql-connector-java-5.1.7-bin.jar
2、
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection connect = DriverManager.getConnection("jdbc:mysql://172.16.1.23:3306/jmuv3", "root", "123.com");
System.out.println("已经连接数据库");
Statement stmt = connect.createStatement();
ResultSet rs = stmt.executeQuery("select * from users limit 10");
while (rs.next()) {
System.out.println(rs.getString("username"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
标签:etc jdbc sql tac str sele statement tor sel
原文地址:https://www.cnblogs.com/wzk-0000/p/9078197.html