import java.sql.*; public class OracleJDBCExample { public static void main(String[] args) throws SQLException { String url = "jdbc:oracle:thin:@localhost:1521/xe"; String username = "your-username"; String password = "your-password"; Connection connection = DriverManager.getConnection(url, username, password); String query = "SELECT * FROM employees"; Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery(query); while (resultSet.next()) { String employeeName = resultSet.getString("name"); int employeeAge = resultSet.getInt("age"); System.out.println("Name: " + employeeName + ", Age: " + employeeAge); } resultSet.close(); statement.close(); connection.close(); } }


上一篇:
下一篇:
切换中文