aspose file tools*
The moose likes JDBC and the fly likes populating the databse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "populating the databse" Watch "populating the databse" New topic
Author

populating the databse

himanshu rai
Greenhorn

Joined: Jun 22, 2011
Posts: 12
using netbeans you get a ready made interface for a javadesktop database application..so i used that for my database on one particular table

it has a date column. so on entering the date in the UI it throws this error message

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: Cannot cast java.lang.String to java.util.Date
at java.lang.Class.cast(Class.java:3002)
at org.jdesktop.beansbinding.Binding.convertReverse(Binding.java:1321)
at org.jdesktop.beansbinding.Binding.getTargetValueForSource(Binding.java:909)
at org.jdesktop.beansbinding.Binding.saveUnmanaged(Binding.java:1268)
at org.jdesktop.beansbinding.Binding.save(Binding.java:1254)
at org.jdesktop.beansbinding.AutoBinding.trySaveThenRefresh(AutoBinding.java:176)
at org.jdesktop.beansbinding.AutoBinding.targetChangedImpl(AutoBinding.java:249)
at org.jdesktop.beansbinding.Binding.targetChanged(Binding.java:1433)
at org.jdesktop.beansbinding.Binding.access$1300(Binding.java:38)
at org.jdesktop.beansbinding.Binding$PSL.propertyStateChanged(Binding.java:1620)
at org.jdesktop.beansbinding.PropertyHelper.firePropertyStateChange(PropertyHelper.java:212)
at org.jdesktop.beansbinding.BeanProperty.notifyListeners(BeanProperty.java:712)
at org.jdesktop.beansbinding.BeanProperty.access$1000(BeanProperty.java:143)
at org.jdesktop.beansbinding.BeanProperty$SourceEntry.cachedValueChanged(BeanProperty.java:369)
at org.jdesktop.beansbinding.BeanProperty$SourceEntry.propertyValueChanged(BeanProperty.java:409)
at org.jdesktop.beansbinding.BeanProperty$SourceEntry.propertyChange(BeanProperty.java:414)
at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
at org.jdesktop.swingbinding.adapters.BeanAdapterBase.firePropertyChange(BeanAdapterBase.java:112)
at org.jdesktop.swingbinding.adapters.JTextComponentAdapterProvider$Adapter$Handler.updateText(JTextComponentAdapterProvider.java:136)
at org.jdesktop.swingbinding.adapters.JTextComponentAdapterProvider$Adapter$Handler.textChanged(JTextComponentAdapterProvider.java:149)
at org.jdesktop.swingbinding.adapters.JTextComponentAdapterProvider$Adapter$Handler.replace(JTextComponentAdapterProvider.java:182)
at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:662)
at javax.swing.text.JTextComponent.replaceSelection(JTextComponent.java:1382)
at javax.swing.text.DefaultEditorKit$DefaultKeyTypedAction.actionPerformed(DefaultEditorKit.java:876)
at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1654)
at javax.swing.JComponent.processKeyBinding(JComponent.java:2869)
at javax.swing.JComponent.processKeyBindings(JComponent.java:2916)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2832)
at java.awt.Component.processEvent(Component.java:6056)
at java.awt.Container.processEvent(Container.java:2084)
at java.awt.Component.dispatchEventImpl(Component.java:4639)
at java.awt.Container.dispatchEventImpl(Container.java:2142)
at java.awt.Component.dispatchEvent(Component.java:4465)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1906)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:752)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1017)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:889)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:717)
at java.awt.Component.dispatchEventImpl(Component.java:4509)
at java.awt.Container.dispatchEventImpl(Container.java:2142)
at java.awt.Window.dispatchEventImpl(Window.java:2612)
at java.awt.Component.dispatchEvent(Component.java:4465)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:618)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:286)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:191)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:186)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:139)


P.S: very new at this so no clue ..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
Welcome to the Ranch

If you need a Date you need a Date. Have a look at the Date class constructors and see whether you can pass "22-Jun-2011" and also how to get a SimpleDateFormat object (or similar) to accept "22-Jun-2011". You can get a Date from SimpleDateFormat. The exception suggests you are simply sending the String "22-Jun-2011" instead of the Date object.
himanshu rai
Greenhorn

Joined: Jun 22, 2011
Posts: 12
i changed the type to java.sql.date..


the error now says Cannot cast java.lang.String to java.util.Date


and i cannont change the type to sql.date beause it is only taking java.util.date or java.util.calendar :S
himanshu rai
Greenhorn

Joined: Jun 22, 2011
Posts: 12
sorry..the error now is

Cannot cast java.sql.Date to java.util.Date
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
I have already told you. You need a Date object.
Pass your date String to a SimpleDateFormat object's parse method, and that returns a java.util.Date object.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: populating the databse