Guest User

jdbc

a guest
Nov 23rd, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import java.sql.DriverManager;
  2. import java.sql.Connection;
  3. import java.sql.SQLException;
  4.  
  5. public class OracleJDBC {
  6.  
  7. public static void main(String[] argv) {
  8.  
  9. System.out.println("-------- Oracle JDBC Connection Testing ------");
  10.  
  11. try {
  12.  
  13. Class.forName("oracle.jdbc.driver.OracleDriver");
  14.  
  15. } catch (ClassNotFoundException e) {
  16.  
  17. System.out.println("Where is your Oracle JDBC Driver?");
  18. e.printStackTrace();
  19. return;
  20.  
  21. }
  22.  
  23. System.out.println("Oracle JDBC Driver Registered!");
  24.  
  25. Connection connection = null;
  26.  
  27. try {
  28.  
  29. connection = DriverManager.getConnection(
  30. "jdbc:oracle:thin:@fourier.cs.iit.edu:1521:orcl", "jpatel98",
  31. "jay57717");
  32.  
  33. } catch (SQLException e) {
  34.  
  35. System.out.println("Connection Failed! Check output console");
  36. e.printStackTrace();
  37. return;
  38.  
  39. }
  40.  
  41. if (connection != null) {
  42. System.out.println("You made it, take control your database now!");
  43. } else {
  44. System.out.println("Failed to make connection!");
  45. }
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment