Advertisement
Guest User

Untitled

a guest
Nov 28th, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. package main;
  2. import java.sql.Connection;
  3. import java.sql.DriverManager;
  4.  
  5. public class Test {
  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/emp", "postgres", "root");
  13.  
  14. if(con!=null)
  15. System.out.println("Connected");
  16.  
  17. java.sql.Statement st = con.createStatement();
  18. String sql = "insert into history values(1,'MolteR','hello world')";
  19.  
  20. st.execute(sql);
  21. }
  22.  
  23. catch(Exception ee)
  24. {
  25. ee.printStackTrace();
  26. }
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement