标签:
public class ConnMysql { public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://localhost:3306/test"; try( Connection cnn = DriverManager.getConnection(url, "root", "123"); Statement stmt = cnn.createStatement(); ResultSet rs = stmt.executeQuery("select * from user")) { while(rs.next()) { System.out.println(rs.getInt(1)+"\t" +rs.getString(2)+"\t"+rs.getString(3)+"\t"+rs.getString(4)); } } } }
标签:
原文地址:http://www.cnblogs.com/masterlibin/p/4780471.html