Results 1 to 3 of 3

Thread: Exception

  1. #1
    Rose88 is offline Member
    Join Date
    Apr 2009
    Posts
    19
    Rep Power
    0

    Default Exception

    here's the exception that I've received :
    Java Code:
    Exception in thread "AWT-EventQueue-0" java.util.MissingFormatArgumentException: Format specifier 's'
    	at java.util.Formatter.format(Formatter.java:2432)
    	at java.util.Formatter.format(Formatter.java:2367)
    	at java.lang.String.format(String.java:2769)
    	at DB.tblDoctor.addDoctor(tblDoctor.java:153)
    	at logic.Doctor.insertDoctor(Doctor.java:13)
    	at GUI.Mazkera.Dr.add_dr.add_dr_btActionPerformed(add_dr.java:252)
    	at GUI.Mazkera.Dr.add_dr.access$0(add_dr.java:244)
    	at GUI.Mazkera.Dr.add_dr$1.actionPerformed(add_dr.java:94)
    	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.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:291)
    	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    	at java.awt.Component.processMouseEvent(Component.java:6263)
    	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    	at java.awt.Component.processEvent(Component.java:6028)
    	at java.awt.Container.processEvent(Container.java:2041)
    	at java.awt.Component.dispatchEventImpl(Component.java:4630)
    	at java.awt.Container.dispatchEventImpl(Container.java:2099)
    	at java.awt.Component.dispatchEvent(Component.java:4460)
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
    	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
    	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
    	at java.awt.Container.dispatchEventImpl(Container.java:2085)
    	at java.awt.Window.dispatchEventImpl(Window.java:2478)
    	at java.awt.Component.dispatchEvent(Component.java:4460)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    	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)
    here's the code where the Exception shows:
    Java Code:
    	public void addDoctor(){
    		String msg=String.format("INSERT INTO tblDoctor" +
    				"((LicenseNum,FirstName,surName,Specialization,StartWorkingDate)" 
    	         	+" VALUES (%s,'%s','%s','%s','%s','%s')"
    	         	,LicenseNum,FirstName,surName,Specialization,StartWorkingDate);
    		try{
    			DBconn.s.execute(msg);
    		}
    		catch(Exception e){
    			System.out.print(e.getMessage());
    		}
    	}
    I don't understand this Exception! can anyone help?

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Have a look at the examples in the Formatter API
    Formatter (Java Platform SE 6)
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Rose88 View Post
    +" VALUES (%s,'%s','%s','%s','%s','%s')"
    ,LicenseNum,FirstName,surName,Specialization,Start WorkingDate);
    Count your Strings; the format specifying String wants to see six of them.

    kind regards,

    Jos

Similar Threads

  1. Replies: 4
    Last Post: 10-25-2010, 07:42 PM
  2. How can I fix this exception?
    By Abder-Rahman in forum Java 2D
    Replies: 1
    Last Post: 12-21-2009, 02:04 AM
  3. Exception
    By sreejit in forum Advanced Java
    Replies: 2
    Last Post: 10-21-2009, 08:26 AM
  4. get exception name
    By jithan in forum New To Java
    Replies: 6
    Last Post: 06-05-2008, 02:29 PM
  5. Replies: 1
    Last Post: 03-08-2008, 06:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •