如果有人可以帮忙并告诉我为什么会有这些错误,我感激不尽。我正在使用java的接口工作,我正在尝试连接MySQL中的数据库,所以我试图用这段代码获取日期
Calendar date = new GregorianCalendar();
int year = date.get(Calendar.YEAR);
int month = date.get(Calendar.MONTH);
int day = date.get(Calendar.DAY_OF_MONTH);
String d = String.valueOf(year) + "-" + String.valueOf(month) + "-" + String.valueOf(day);
我想插入日期:
String query="INSERT INTO bitacora (id,nombre,apellidos,telefono,fecha,transaccion) VALUES ( "+Integer.parseInt(txtId.getText())+",'"+txtNombre.getText()+"','"+txtApellido.getText()+"',"+Integer.parseInt(txttelefono.getText())+",'"+d+"','"+txttrans.getText()+"')"d
但我收到错误
No puede conectarse a la base de datos
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at interfaz.actionPerformed(interfaz.java:57)