Using MySQL with Java

Published July 26, 2025 By Sai Sree Ram Gundepudi

Java JDBC Example

Connection con = DriverManager.getConnection("jdbc:mysql://localhost/employees", "user", "pass");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM employees");
while(rs.next()) {
  System.out.println(rs.getString("name"));
}

Was this solution helpful?

Your feedback helps improve our technical knowledge repository.

Share this article