import java.sql.*; public class Ojdbc10Example { public static void main(String[] args) { try { Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "username", "password"); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery("SELECT * FROM employees"); while (resultSet.next()) { String firstName = resultSet.getString("first_name"); String lastName = resultSet.getString("last_name"); System.out.println("Name: " + firstName + " " + lastName); } resultSet.close(); statement.close(); connection.close(); } catch (SQLException e) { e.printStackTrace(); } } } properties jdbc.url=jdbc:oracle:thin:@localhost:1521:XE jdbc.username=username jdbc.password=password


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