I have been trying to insert data from an app to a database, but always get a syntax error relating to a UUID number that will be the customer's ID, and primary key for the table. The column is set as BIGINT
, it always returns. Here is the code:
String a = txtNombre.getText();
String b = txtApellido.getText();
String c = txtLetras.getText();
String d = txtFin.getText();
String e = txtMensual.getText();
e = e.replaceAll("[^\\d.]","");
String f = txtfecha.getText();
String g = txtdeuda.getText();
g = g.replaceAll("[^\\d.]","");
int c1 = Integer.parseInt(c);
long result = UUID.nameUUIDFromBytes((a+b).getBytes()).getMostSignificantBits();
String x = "" + result + "";
String sbStr = x.substring(0, 6);
sbStr = sbStr.replaceAll("[^\\d.]","");
long csId = Long.parseLong(sbStr);
JOptionPane.showInternalMessageDialog(dskPane, "Cliente Ingresado con id#" + csId, "Cliente a Base de"
+ "Datos", 1, null);
connectMyDB con = new connectMyDB();
Statement state = null;
try {
Connection charlie = con.connect();
state = charlie.createStatement();
String insert = "insert into APP.CLIENTES("+csId+",'"+a+"',"
+ "'"+b+"',"+c1+","+d+","+e+",'"+f+"',"+g+")";
state.executeUpdate(insert);
System.out.println(insert);
if(state!=null) {
state.close();
charlie.close();
}
} catch(SQLException ex) {
System.out.print(ex);
}
I always get sql.SQLSyntaxErrorException: Syntax error: Encountered "61297" at line 1, column 26
. Is there a way to avoid that?