MySQL - Problema al insertar en una base de datos

 
Vista:
sin imagen de perfil
Val: 13
Ha disminuido su posición en 3 puestos en MySQL (en relación al último mes)
Gráfica de MySQL

Problema al insertar en una base de datos

Publicado por juan (8 intervenciones) el 21/06/2018 18:18:10
Hola a todos, tengo el siguiente problema. Estoy intentando insertar un registro en una base de datos y me da el siguiente error:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CLIENTES(NIF, NOMBRE, APELLIDOS, NACIMIENTO) VALUES ('20183041n', 'a', 'a', '201' at line 1"

Os pongo parte del programa para que podáis ver donde tengo el error.

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
private static final String INSERT = "INSERT INTRO CLIENTES(NIF, NOMBRE, APELLIDOS, NACIMIENTO) VALUES (?, ?, ?, ?)";
 
public static void insertar(Cliente objCliente) throws Exception {
    DataSource data = null;
    PreparedStatement st = null;
 
    try {
        data = new DataSource();
        st = data.getStatement(INSERT);
        st.setString(1, objCliente.getNif());
        st.setString(2, objCliente.getNombre());
        st.setString(3, objCliente.getApellidos());
        st.setDate(4, new java.sql.Date(objCliente.getNacimiento().getTime()));
 
        data.ejecutarUpdate(st);
    } catch (SQLException ex) {
        System.err.println(ex.getMessage());
        throw new Exception(ex.getMessage());
    } finally {
        if (st != null) {
            st.close();
        }
        if (data != null) {
            data.cerrarConexion();
        }
    }
}

Gracias por vuestra ayuda.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 13
Ha disminuido su posición en 3 puestos en MySQL (en relación al último mes)
Gráfica de MySQL

Problema al insertar en una base de datos

Publicado por juan (8 intervenciones) el 21/06/2018 18:45:56
ya esta solucionado:

private static final String INSERT = "INSERT INTRO CLIENTES(NIF, NOMBRE, APELLIDOS, NACIMIENTO) VALUES (?, ?, ?, ?)";

private static final String INSERT = "INSERT INTO CLIENTES(NIF, NOMBRE, APELLIDOS, NACIMIENTO) VALUES (?, ?, ?, ?)";

Habia puesto INTRO en vez de INTO.

Gracias .
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar