Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.Statement;
  4.  
  5. public class Connect
  6. {
  7. public static void main(String[] args)
  8. {
  9. try
  10. {
  11. Class.forName("org.postgresql.Driver");
  12. Connection con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres", "ankara");
  13. if(con != null)
  14. System.out.println("Connected");
  15.  
  16. Statement st = con.createStatement();
  17. String sql;
  18. //st.executeUpdate(sql);
  19. st.close();
  20. con.close();
  21. }
  22. catch(Exception ee)
  23. {
  24. ee.printStackTrace();
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement