Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import java.sql.*;
  2. public class JDBC_Experiment {
  3. // JDBC Driver name and DB URL
  4. static String Driver = "Placeholdervalue"; // this will be updated once the server connection name is figured out
  5. static String URL = "Placeholdervalue"; // this will be updated once the server connection name is figured out
  6. static final String JDBC_DRIVER = Driver;
  7. static final String DB_URL = URL;
  8.  
  9. // creadentials
  10. static final String USER = "username";
  11. static final String PASS = "password";
  12.  
  13. public static void main(String[] args) {
  14. Connection conn = null;
  15. Statement stmt = null;
  16.  
  17. // try and catch statement
  18. try {
  19. Class.forName("Placeholdervalue"); // this will be updated once the connection is sorted
  20. System.out.println("Connecting to database...");
  21. }catch(SQLException se) {
  22. se.printStackTrace();
  23.  
  24. } catch(Exception e) {
  25. e.printStackTrace();
  26. } finally {
  27.  
  28. try {
  29. if(stmt !=null)
  30. stmt.close();
  31. }catch(SQLException se2) {
  32.  
  33. } //
  34. }
  35. } // end main
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement