Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- /**
- * Example Java Schemaverse connection, query and close.
- * Assumes that you have org.postgresql.Driver on your path
- */
- public class SchemaverseExample {
- public static void main(String[] args) throws Exception {
- // Force a load of the JDBC driver into the Driver manager
- Class.forName("org.postgresql.Driver");
- // Open a connection to the database
- Connection conn = DriverManager.getConnection("jdbc:postgresql://db.schemaverse.com/schemaverse", "<Your User Name>", "<Your Password>");
- // Create a query, execute it, and get the first row of results
- Statement statement = conn.createStatement();
- ResultSet rs = statement.executeQuery("SELECT username, balance, fuel_reserve FROM my_player");
- rs.next();
- // Print out what we retrieved
- System.out.println("username = " + rs.getString("username") + ", balance = " + rs.getInt("balance") + ", fuel_reserve = " + rs.getInt("fuel_reserve"));
- // Clean up before we exit
- rs.close();
- statement.close();
- conn.close();
- }
- }
Add Comment
Please, Sign In to add comment