Advertisement
Guest User

Untitled

a guest
May 11th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. package javaapplication1;
  2. import java.sql.*;
  3. import java.io.Console;
  4. import oracle.jdbc.pool.OracleDataSource;
  5. public class JavaApplication1 {
  6.     /**
  7.      * @param args the command line arguments
  8.      * @throws java.sql.SQLException
  9.      */
  10.     public static void main(String[] args) throws SQLException {
  11.         Console cons = System.console();
  12.         Connection conn = null;
  13.         if(cons!=null){
  14.             do{
  15.                 try{
  16.                     OracleDataSource ods = new OracleDataSource();
  17.                     ods.setURL("jdbc:oracle:thin:@//192.168.117.238:1521/xe");
  18.                     String user = cons.readLine("Inserire nome utente: ");
  19.                     String pass = new String(cons.readPassword("Inserire password: "));
  20.                     ods.setUser(user);
  21.                     ods.setPassword(pass);
  22.                     conn = ods.getConnection();
  23.                 }catch(SQLException e){
  24.                     System.out.println("Errore: " + e.getMessage());
  25.                 }
  26.             }while(true);
  27.         }else{
  28.             System.out.println("Errore di lettura da console");
  29.             System.exit(1);
  30.         }
  31.     }
  32.    
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement