我在检查ResultSet是否关闭时收到错误,这是我在netbeans 7.3中得到的实际错误:
线程“AWT-EventQueue-0”中的异常java.lang.UnsupportedOperationException:尚不支持操作 at sun.jdbc.odbc.JdbcOdbcResultSet.isClosed(JdbcOdbcResultSet.java:6753)
以下是我收到错误的代码。
try{
if(!rs.isClosed());
rs.close();
}catch(SQLException ex){
JOptionPane.showMessageDialog(rootpane, ex);
}
Thanx提前为您提供帮助。
答案 0 :(得分:2)
显然,驱动程序没有实现该方法并抛出java.lang.UnsupportedOperationException
。根据供应商(Oracle,IBM,Derby,...),它可以实现JDBC的某些功能。您只能关闭连接。这释放了所有资源。
答案 1 :(得分:-1)
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.