if i want to insert Date to sql. I have to use : import java.sql.Date; OR
import java.util.Date;?
If i'm using the first one: then I press "Save" it's not doing anythging
If I'm using the second one: then i press "Save" Error: "Error saving
employee:java.util.Date cannot be cast to java.sql.Date"
please help!
+Vytenis Surdokas I created blog post to handle inserting dates. Here's the link: //www.luv2code.com/2015/01/06/java-jdbc-tutorial-inserting-date-and-time/Let me know if you need anything else :-)
+christian obar Hi Christian,a couple of questions:1. Did you make any changes to the original source code?2. Can you post the exception stack trace here?thanks.
I am getting error when i am adding customer
the error is:
Database connection successcom.mysql.jdbc.JDBC4Connection@7390c702
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException
at java.sql.Time.valueOf(Unknown Source)
at gui.AddCustomerDialog$2.actionPerformed(AddCustomerDialog.java:253)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
+etechno mate ok, I see that you added your modifications to the code.Based on your source code at the gist link, you have a problem converting java.util.Date to java.sql.Date. You should make the following changes:Lines 275-276Replace: Customers tempCustomers = new Customers(id, firstName, lastName, priContact, eMail, secContact, address, bestContactTime, (java.sql.Date) createDate);With Customers tempCustomers = new Customers(id, firstName, lastName, priContact, eMail, secContact, address, bestContactTime, new java.sql.Date(createDate.getTime()));notice how the java.sql.Date constructor is used.Let me know how this works for you.
+etechno mate thanks for giving error message. Were any changes made to original source code?I am trying to determine if there is a big with code provided from my video. Or if there is a big with changes you made. This will help me troubleshoot the issue.
Complete Error is:Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException at java.sql.Time.valueOf(Unknown Source) at gui.AddCustomerDialog$2.actionPerformed(AddCustomerDialog.java:253) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
Thanks for the link. I was not aware of this. :-(Anyways, you should pose your question to the Eclipse development team, Since they are closer to the issue.
+Denis RM Hi Denis, No additonal plugin to install. This is already bundled in Eclipse. In Eclipse:1. Select File > New > Other ... 2. WindowBuilder > Swing Designer > JFramefrom there you can use the component palette to build your GUI.There is also documentation available on the WindowBuilder tool: //goo.gl/4EBkds
+Henrik Mjaaland Hey, That's interesting. This is the step I used to create the JFrame. Right-click > New > Other > WindowBuilder > Swing Designer > JFrameLet me know if you still have the problem.