Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void getHighScores() {
- try {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- } catch (ClassNotFoundException e) {
- System.out.println("Where is your Oracle JDBC Driver?");
- e.printStackTrace();
- return;
- }
- Connection connection = null;
- try {
- connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521/xe", "STUDENT", "STUDENT");
- } catch (SQLException e) {
- System.out.println("Connection Failed! Check output console");
- e.printStackTrace();
- return;
- }
- try {
- Statement stmt = connection.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT * FROM HIGHSCORE ");
- System.out.println("Top Players");
- while (rs.next())
- System.out.println(rs.getString(1) + " " + rs.getInt(2));
- connection.close();
- } catch (Exception e)
- {
- System.out.println(e);
- }
- }
- connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521/xe", "STUDENT", "STUDENT");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement