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.
Gracias por vuestra ayuda.
"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


0