Ver Mensaje Individual
  #8 (permalink)  
Antiguo 11/08/2006, 05:26
Raiko
 
Fecha de Ingreso: noviembre-2005
Mensajes: 97
Antigüedad: 21 años
Puntos: 0
Prueba con esto, te falta el rs.next() para leer los resultados de BD y he quitado algo de código (si no te gusta con que pongas rs.next() en el tuyo también debería ir)

Código PHP:
public void insertar(int filas)throws SQLException, Exception {

            
filas = contfilas();
            
Connection con = null;
            
Statement sentencia = null;
            
String URL = "jdbc:mysql://localhost/visitas";
            
String query ="";
            
PreparedStatement ps = null;
            
ResultSet rs = null;
            
int resultado;
                try {        
                
//cargamos el Driver
                    
Class.forName("com.mysql.jdbc.Driver");
                
//conectamos con la base de datos 
                    
con = DriverManager.getConnection(URL, "root", "");
                    
query = "SELECT MAX(Identificador) AS CANTIDAD FROM visitadentro";
                    
ps = (PreparedStatement) con.prepareStatement(query);
                    
rs = ps.executeQuery();
                    if (
rs.next()){
                        
identificador = (rs.getInt("CANTIDAD") != null) ? (rs.getInt("CANTIDAD") + 1) : 1;
                    }else{
                        
identificador = 1;
                    }
                                              
                    
inserta = "INSERT INTO visitadentro (Identificador, Fecha, NombreEmpresa,Visitado, Motivo) " +
                               
"VALUES("+identificador+", NOW(), '"+nombre+"','"+visitado+"','"+motivo+"')";
                 
//Creamos el ststement
                    
sentencia = con.createStatement();
                 
//Ejecutamos la actualizacion de la tabla
                    
sentencia.executeUpdate(inserta);
                    
sentencia.close();