Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication1;
- import java.sql.*;
- import java.io.Console;
- import oracle.jdbc.pool.OracleDataSource;
- public class JavaApplication1 {
- /**
- * @param args the command line arguments
- * @throws java.sql.SQLException
- */
- public static void main(String[] args) throws SQLException {
- Console cons = System.console();
- Connection conn = null;
- if(cons!=null){
- do{
- try{
- OracleDataSource ods = new OracleDataSource();
- ods.setURL("jdbc:oracle:thin:@//192.168.117.238:1521/xe");
- String user = cons.readLine("Inserire nome utente: ");
- String pass = new String(cons.readPassword("Inserire password: "));
- ods.setUser(user);
- ods.setPassword(pass);
- conn = ods.getConnection();
- }catch(SQLException e){
- System.out.println("Errore: " + e.getMessage());
- }
- }while(true);
- }else{
- System.out.println("Errore di lettura da console");
- System.exit(1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement