线程“AWT-EventQueue-0”中的异常java.lang.NumberFormatException:对于输入字符串:“”?

时间:2017-03-31 13:36:52

标签: java mysql awt

如果有人可以帮忙并告诉我为什么会有这些错误,我感激不尽。我正在使用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)

0 个答案:

没有答案