Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. package totalpos;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6. import java.sql.Statement;
  7. import java.util.logging.Level;
  8. import java.util.logging.Logger;
  9.  
  10. /**
  11.  *
  12.  * @author shidalgo
  13.  */
  14. public class ConectionDrivers {
  15.     private static Connection connections[];
  16.     private static Statement statements[];
  17.  
  18.     protected static boolean initialize(){
  19.         connections = new Connection[Constants.numberConnection];
  20.         for (int i = 0; i < connections.length; i++) {
  21.             try {
  22.                 String s = "jdbc:mysql://" + Constants.dbHost + "/" +
  23.                             Constants.dbName + "?user=" + Constants.dbUser + "&password=" + Constants.dbPassword;
  24.                 System.out.println(s);
  25.                 connections[i] = DriverManager.getConnection(s);
  26.                 statements[i] = connections[i].createStatement();
  27.                
  28.             } catch (SQLException ex) {
  29.                 Logger.getLogger(ConectionDrivers.class.getName()).log(Level.SEVERE, null, ex);
  30.                 return false;
  31.             }
  32.  
  33.         }
  34.  
  35.        
  36.  
  37.         return true;
  38.     }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement