Advertisement
Guest User

Untitled

a guest
Apr 27th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. import java.awt.HeadlessException;
  2. import java.sql.Connection;
  3. import java.sql.DriverManager;
  4. import java.sql.SQLException;
  5. import javax.swing.JOptionPane;
  6.  
  7. public class ConnectDb
  8. {  
  9.     public static Connection connectDb()
  10.     {      
  11.         try
  12.         {
  13.             Class.forName("oracle.jdbc.driver.OracleDriver");
  14.         }
  15.         catch (ClassNotFoundException e)
  16.         {
  17.             JOptionPane.showMessageDialog(null, e);
  18.         }
  19.         try
  20.         {          
  21.             Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORA2015","grX_login","hasło");
  22.             return conn;            
  23.         }
  24.         catch (SQLException | HeadlessException e)
  25.         {
  26.             JOptionPane.showMessageDialog(null, "Brak połaczenia z bazą danych!");
  27.         }    
  28.         return null;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement