Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class Runner {
- public static void main(String[] args) throws SQLException {
- Connection conn = null;
- Statement stmt = null;
- try {
- Class.forName("org.postgresql.Driver");
- conn = DriverManager
- .getConnection("jdbc:postgresql://localhost:5432/projekt_DBS",
- "bruno", "fiit");
- conn.setAutoCommit(false);
- System.out.println("Opened database successfully");
- stmt = conn.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT * FROM cesta LIMIT 1;");
- rs.next();
- int pocet = rs.getInt("id_linka");
- System.out.println(pocet);
- rs.close();
- stmt.close();
- conn.close();
- } catch (Exception e) {
- System.err.println(e.getClass().getName() + ": " + e.getMessage());
- System.exit(0);
- }
- System.out.println("Operation done successfully");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement