Mostrando entradas con la etiqueta java. Mostrar todas las entradas
Mostrando entradas con la etiqueta java. Mostrar todas las entradas

martes, 17 de septiembre de 2013

restart and stop apache tomcat in linux

# Restart
sudo /etc/init.d/tomcat7 restart 

# Stop
sudo /etc/init.d/tomcat7 stop

miércoles, 4 de julio de 2012

Instalar jdownloader en ubuntu

Abrir una terminal (ctrl + alt + t) y ejecutar estos tres simples pasos:

sudo add-apt-repository ppa:jd-team/jdownloader
sudo apt-get update
sudo apt-get install jdownloader

domingo, 24 de junio de 2012

Class DB

la clase db de ayudita para el parcial:

import java.sql.*;import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

public class DB {
    private Connection cn;
    private Statement st;
    private ResultSet rs;
 
    public DB(){
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
    public void conectar(){
        try {
            this.cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/dvd", "root", "");
            this.st = cn.createStatement();
        } catch (SQLException ex) {
            Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
    public void desconectar(){
        try {
            this.st.close();
            this.cn.close();
        } catch (SQLException ex) {
            Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
        }
     
    }
 
    public synchronized int getCount(String tabla){
        int tmp = 0;
        try {
            this.conectar();
            rs = st.executeQuery("select count(*) from "+ tabla);
            if(rs.first()){
                tmp = rs.getInt(1);
            }
            this.desconectar();
        } catch (SQLException ex) {
            Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
        }
        return tmp;
     
    }
 
    public void limpiarBase(){
        try {
            this.conectar();
            this.st.executeUpdate("truncate table dvd");
            this.desconectar();
        } catch (SQLException ex) {
            Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
    public void setNuevoDvd(dvd D){
             
    }
 
    public ArrayList getFromDb(String consulta){
        ArrayList tmpReturn = new ArrayList();
        try {
            this.conectar();
            this.rs = this.st.executeQuery(consulta);
         
            while(rs.next()){
                ArrayList tmpFila = new ArrayList();
                for(int i = 1; i <= rs.getMetaData().getColumnCount(); i++){
                    tmpFila.add(rs.getObject(i));
                 
                }
                tmpReturn.add(tmpFila);
           
            }
            this.desconectar();
        } catch (SQLException ex) {
            Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
        }
        return tmpReturn;
    }
 
    private void setDvdToDb(){
    }
 
}