Advertisement
Guest User

Untitled

a guest
Aug 10th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1.  
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.Statement;
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. public class Base {
  15.     public ResultSet rs;
  16.      public String usuario,pass,categoria;
  17.     public Connection conexion = null;
  18.     public Statement s;
  19.    
  20.     public void AvtivarDriver(){
  21.         try{
  22.             Class.forName("com.mysql.jdbc.Driver");
  23.             }catch(Exception e){
  24.                 //exception
  25.             }
  26.     }
  27.  
  28.     public void ConexionDB(){
  29.         try{
  30.         conexion = DriverManager.getConnection("jdbc:mysql://localhost/datos","root","labtel");
  31.         }catch(Exception e){
  32.             //exception
  33.         }
  34.        
  35.     }
  36.  
  37.     public void PeticionCategoria(String U, String P){
  38.         try{
  39.         s = conexion.createStatement();
  40.         rs = s.executeQuery("SELECT * FROM usuarios WHERE nombre=\""+U+"\" AND password=\""+P+"\"");
  41.         rs.next();
  42.  
  43.         this.usuario = rs.getString("nombre");
  44.         this.pass = rs.getString("password");
  45.         this.categoria = rs.getString("categoria");
  46.         }catch(Exception e){
  47.            
  48.         }
  49.  
  50.     }
  51.    
  52.    
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement