Guest User

Untitled

a guest
Dec 10th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. /**
  4. * Example Java Schemaverse connection, query and close.
  5. * Assumes that you have org.postgresql.Driver on your path
  6. */
  7. public class SchemaverseExample {
  8.  
  9. public static void main(String[] args) throws Exception {
  10. // Force a load of the JDBC driver into the Driver manager
  11. Class.forName("org.postgresql.Driver");
  12.  
  13. // Open a connection to the database
  14. Connection conn = DriverManager.getConnection("jdbc:postgresql://db.schemaverse.com/schemaverse", "<Your User Name>", "<Your Password>");
  15.  
  16.  
  17. // Create a query, execute it, and get the first row of results
  18. Statement statement = conn.createStatement();
  19. ResultSet rs = statement.executeQuery("SELECT username, balance, fuel_reserve FROM my_player");
  20. rs.next();
  21.  
  22. // Print out what we retrieved
  23. System.out.println("username = " + rs.getString("username") + ", balance = " + rs.getInt("balance") + ", fuel_reserve = " + rs.getInt("fuel_reserve"));
  24.  
  25. // Clean up before we exit
  26. rs.close();
  27. statement.close();
  28. conn.close();
  29. }
  30.  
  31. }
Add Comment
Please, Sign In to add comment