用my eclipse运行java application时出现错误提示:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException
at java.sql.Date.valueOf(Date.java:138)
at com.wsy.iframe.BookAddIFrame$addBookActionListener.actionPerformed(BookAddIFrame.java:252)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6290)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6055)
at java.awt.Container.processEvent(Container.java:2039)
at java.awt.Component.dispatchEventImpl(Component.java:4653)
at java.awt.Container.dispatchEventImpl(Container.java:2097)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4575)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4236)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4166)
at java.awt.Container.dispatchEventImpl(Container.java:2083)
at java.awt.Window.dispatchEventImpl(Window.java:2482)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:648)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:607)
at java.awt.EventQueue$1.run(EventQueue.java:605)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:621)
at java.awt.EventQueue$2.run(EventQueue.java:619)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:618)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
补充:怎么解决这些问题?
追问:int i=Dao.Insertbook(ISBNs,bookTypes, bookNames, writers, translators, publishers, java.sql.Date.valueOf(pubDates),Double.parseDouble(prices));
是不是这个地方有问题啊
答案:at java.sql.Date.valueOf(Date.java:138)
一般的时候都是用 java.util.Date
在进行类型转换的时候要注意格式才行 如果使用 java.util.Date 的话需要用SimpleDateFormat
java.sql.Date.valueOf(String s)里面的参数应该是String类型 不应该用Date类型
所以才会报这个错误
其他:能否提供下代码 请求参数非法问题你..把BookAddIFrame类的第252行左右的代码发上来 at java.sql.Date.valueOf(Date.java:138)
java.sql.date 与java.util.Date 中的Date是不同的。
一般的时候都是用 java.util.Date 在进行类型转换的时候要注意格式才行 如果使用 java.util.Date 的话需要用SimpleDateFormat java.sql.Date.valueOf(String s)里面的参数应该是String类型 不应该用Date类型,所以才会报这个错误。
上一个:jdk6.0的官方帮助文档在哪里可以下载到?
下一个:现在学JAVA的好泛滥,到底该不该学,需求的少了价值也就降低了。