
Ingreso de datos por teclado a mysql error
Publicado por Patricio (2 intervenciones) el 30/04/2013 16:48:19
hola estoy tratando de ingresar datos por teclado a para que se ingrese a la base de datos, bueno lo mismo tambien para eliminar y me sale el siguiente error:
Sql Error: Unknown column 'nom' in 'field list'
Sql Estado: 42S22
Error: 1054
Sql Error: Unknown column 'nom' in 'field list'
Sql Estado: 42S22
Error: 1054
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sqlConexion.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.*;
import java.util.Scanner;
public class TestMain {
public static void main(String[] args)throws SQLException {
int id, nom,ciu;
conexion conexion = new conexion();
conexion.openConexion();
Scanner teclado = new Scanner(System.in);// declaramos la variable para guardar el dato
//insertando un dato paguirre: puede servir para eliminar datos???
Comando comando = new Comando();
// pido el primer dato
System.out.println("Ingrese ID a Insertar");
id= teclado.nextInt();
System.out.println("Ingrese Nombre a Insertar");
nom= teclado.nextInt();
System.out.println("Ingrese Ciudad o Pais a Insertar");
ciu= teclado.nextInt();
// -------------------------------------------------------
comando.setConsulta("INSERT INTO cliente VALUES(id,nom,ciu)");
comando.updateSQL();
//recuperando los datos
Comando comando2 = new Comando("select * from cliente");
ResultSet result = comando2.ejecutarSQL();
while(result.next()){
System.out.println(result.getString("id"));
System.out.println(result.getString("nombre"));
System.out.println(result.getString("direccion"));
System.out.println("----------------------------");
}
conexion.closeConexion();
}
}
Valora esta pregunta


0