-2

I am getting error while checking whether the ResultSet is closed or not, here is the actual error I got in netbeans 7.3 :

Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Operation not yet supported at sun.jdbc.odbc.JdbcOdbcResultSet.isClosed(JdbcOdbcResultSet.java:6753)

Here is the code in which I got the error.

try{
    if(!rs.isClosed());
    rs.close();
}catch(SQLException ex){
    JOptionPane.showMessageDialog(rootpane, ex);
}

Thanx in Advance for your help.

MMujtabaRoohani
  • 483
  • 4
  • 19

2 Answers2

2

Apparently, the driver does not implement the method and throws java.lang.UnsupportedOperationException. Depending on the vendor (Oracle, IBM, Derby, ...), it can implement certain functionality of JDBC. You could only close the connection. This frees all resources.

Paul Vargas
  • 41,222
  • 15
  • 102
  • 148
  • are you trying to say that i should not use the if condition? – MMujtabaRoohani Jun 04 '13 at 13:18
  • Or you can use a different Driver, one that implements the `isClosed()` method. You are using a generic Driver, but there are specific Driver for the database you are using (MySQL, MS Server, Oracle, Derby...) and they are better solutions than the generic one. – eternay Jun 04 '13 at 13:42
  • The problem is that I even used the way you told but I am getting the same error while closing ResultSet that it is closed and the interesting thing is that I also used data from resultSet so how it is closed. – MMujtabaRoohani Jun 04 '13 at 17:31
  • No need to close it. Just close the connection when the app finish using it. – Paul Vargas Jun 04 '13 at 17:37
-2
package audio;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.swing.JButton;
import javax.swing.JFrame;
import javazoom.jl.player.Player;


public class sound4 extends JFrame implements ActionListener{
   MediaPlayer mediaPlayer;
    JButton button,button2;
    Player player;
    Clip clip ;

    public sound4()
    {
        setLayout(new FlowLayout());
        setSize(300,300);
         button =new JButton("Click me");
       add(button);
       button.addActionListener(this);
       button2 =new JButton("exit");
       add(button2);
       button2.addActionListener(this);
    }

    public static void main(String[] args)
    {


           java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new sound().setVisible(true);
            }
        });


    }

    @Override
    public void actionPerformed(ActionEvent e) {

        if(e.getSource()==button)
        {
        /*String bip = "music1.mp3";
Media hit = new Media(bip);
 mediaPlayer = new MediaPlayer(hit);
 mediaPlayer.play();
 if(e.getSource()==button2)
        {
            mediaPlayer.dispose();
        }


        }*/


            //int alarmname =  cmbalarm.getSelectedIndex();

 // String playalarm = "";//String.valueOf(alarmname)+ ".wav";
  try{
         //if (cmbalarm.getSelectedIndex()==alarmname){
     AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File("C:\\Users\\nida\\Music\\music1.mp3"));
        clip = AudioSystem.getClip();
       clip.open(inputStream);
        //clip.start();


       if(e.getSource()==button2)
            {
               clip.close();
               clip.stop();
              // System.exit(0);

            }
        else
        {
             clip.loop(Clip.LOOP_CONTINUOUSLY);
        }
       Thread.sleep(10000);
    }
     catch (Exception ex) {
       }


    }



    }
}
Am trying to run Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.
    at audio.sound.actionPerformed(sound.java:81)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    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:6535)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6300)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4891)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4713)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
    at java.awt.Container.dispatchEventImpl(Container.java:2280)
    at java.awt.Window.dispatchEventImpl(Window.java:2750)
    at java.awt.Component.dispatchEvent(Component.java:4713)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
this code but it gives that errors.
Aliza
  • 1