This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes TextField Data to Show in JTextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "TextField Data to Show in JTextArea" Watch "TextField Data to Show in JTextArea" New topic
Author

TextField Data to Show in JTextArea

david foley
Ranch Hand

Joined: Dec 01, 2012
Posts: 58
I'm Stuck on this for about 1 hour, can't seem to figure out what i need to get done.

What i am hoping to do is WHen i click Next, It moves and fills the Text Fields with the Database Records, But what i like is that
The JTextArea will show any info inside the Patient History Table, that person, and refresh when i click next to a new Record








I am getting the Following Errors
java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at com.mysql.jdbc.PreparedStatement.checkAllParametersSet(PreparedStatement.java:2603)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2578)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2502)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2259)
at DoctorQueries.PatientHistory(DoctorQueries.java:351)
at DoctorsRecordDisplay.ConnectButtonActionPerformed(DoctorsRecordDisplay.java:667)
at DoctorsRecordDisplay.access$5(DoctorsRecordDisplay.java:643)
at DoctorsRecordDisplay$6.actionPerformed(DoctorsRecordDisplay.java:393)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:696)
at java.awt.EventQueue$4.run(EventQueue.java:694)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
java.lang.NullPointerException
at DoctorQueries.PatientHistory(DoctorQueries.java:381)
at DoctorsRecordDisplay.ConnectButtonActionPerformed(DoctorsRecordDisplay.java:667)
at DoctorsRecordDisplay.access$5(DoctorsRecordDisplay.java:643)
at DoctorsRecordDisplay$6.actionPerformed(DoctorsRecordDisplay.java:393)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:696)
at java.awt.EventQueue$4.run(EventQueue.java:694)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

You need to call PatientHistory.setXXX(1, someValue) before you call PatientHistory.executeQuery(), where XXX is the appropriate method for the type of PatiendId.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
david foley
Ranch Hand

Joined: Dec 01, 2012
Posts: 58
Rob Spoor wrote:You need to call PatientHistory.setXXX(1, someValue) before you call PatientHistory.executeQuery(), where XXX is the appropriate method for the type of PatiendId.




So by giving PatientHistory a Value, should clear this problem ? can i set 1 to null
david foley
Ranch Hand

Joined: Dec 01, 2012
Posts: 58
I'm after fixing up the code a small bit








When i Run it, Nothing was being shown on the TextArea, So i add in A System.out To see what was coming up

what i am getting on the Console is
HELLO
[]

Looks to me its an Empty Array..
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Where do you create a History object and add it to the results list?
david foley
Ranch Hand

Joined: Dec 01, 2012
Posts: 58
I have a Class Called History with Setters and Getters.

But i have Solved this Problem I don't think its the Most practical way of doing Things i Added another Database Connection inside a Button Action Listener.

So, In fact i have now 2 Connections going to the Database.


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: TextField Data to Show in JTextArea
 
Similar Threads
addin two matrices.no display in final cell in the result table:java.lang.NullPointerException error
ResultSet
SQL Remove.
NullPointerException thrown by method drawImage()
Problem reading database.