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));

			}
		}
	}
}

 

相关文章:

  • 2022-01-29
  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2021-08-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
  • 2022-03-05
  • 2021-06-08
  • 2022-12-23
相关资源
相似解决方案