Advertisement
Guest User

Untitled

a guest
Jan 7th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. package bank;
  2.  
  3. import java.sql.*;
  4.  
  5. public class DBOperations {
  6.  
  7.     public static Connection connect( boolean local) throws SQLException{
  8.         Connection connection = null;
  9.                
  10.                 String username;
  11.                 String password;
  12.                
  13.                 if(local){
  14.  
  15.                     username="root";
  16.                     password="";
  17.                     connection = DriverManager.getConnection(
  18.                                 //"jdbc:oracle:thin:@localhost:1521/xe", username,   //moj adres IP
  19.                                 "jdbc:mysql://127.0.0.1:3306/bank", username,   //moj adres IP
  20.                 password);//open the connection
  21.                 }
  22.                 else{   //logowanie do bazy w necie - DONOT supported YET
  23.                     username="pwr_16_17_L_015226029";
  24.                     System.out.println("jest konekcja pozalokalna");
  25.                     // prawie zapomniałem usunac haslo
  26.                     password="";
  27.                     connection = DriverManager.getConnection(
  28.                 "jdbc:oracle:thin:@156.17.43.90:1521:xe", username, //serwer Pwr
  29.                 password);//open the connection
  30.                 }
  31.         return connection;
  32.     }
  33.        
  34.        
  35.  
  36.          // metoda nieuzywana, a moznaby
  37.  
  38.     public static void checkLib() throws ClassNotFoundException{
  39.         Class.forName("oracle.jdbc.driver.OracleDriver");
  40.     }
  41.    
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement