Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.Statement;
  4.  
  5. public class Main {
  6. static final String JDBC_DRIVER = "org.h2.Driver";
  7. static final String DB_URL = "jdbc:h2:~/test";
  8.  
  9. // Database credentials
  10. static final String USER = "sa";
  11. static final String PASS = "";
  12.  
  13. public static void main(String[] args) {
  14. System.out.println("Hello, friend.");
  15.  
  16. Connection conn = null;
  17. Statement stmt = null;
  18.  
  19. try {
  20. Class.forName(JDBC_DRIVER);
  21.  
  22. System.out.println("Connecting to database...");
  23. conn = DriverManager.getConnection(DB_URL, USER, PASS);
  24.  
  25. System.out.println("Creating table in given database...");
  26. stmt = conn.createStatement();
  27.  
  28. conn.close();
  29. stmt.close();
  30. } catch(Exception e) {
  31. e.printStackTrace();
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement