我試圖執行一個jar文件,覆蓋一些Java原件接口與數據庫連接,改變方法setBoolean
,包括接收參數的對象。
這是原來的接口方法:
void setBoolean(int parameterIndex, boolean x) throws SQLException;
這就是我的變化:
void setBoolean(int parameterIndex, Boolean x) throws SQLException;
我的變化在接口java.sql.PreparedStatement中提出。對於要叫我的變化,當我開始我使用該命令的應用程序:
java -verbose:class -Xbootclasspath/p:C:/Users/user/Desktop/myproject/src/main/java -jar safepdv.jar
用命令「-verbose:類」我可以確認我的變化,類被加載。
然而,當方法setBoolean
是由應用程序調用,他是不是成立,我的回報是:
Exception in thread "AWT-EventQueue-0" [Loaded java.lang.Throwable$WrappedPrintStream from C:\Program Files\Java\jre1.8.0_91\lib\rt.jar]
java.lang.NoSuchMethodError: java.sql.PreparedStatement.setBoolean(IZ)V
at com.t2tierp.pafecf.controller.ConfigurationController.updateCS(ConfigurationController.java:613)
at com.t2tierp.pafecf.view.OpenMoviment.validaCamposLogin(OpenMoviment.java:448)
at com.t2tierp.pafecf.view.OpenMoviment.passwordTextSenhaUsuarioActionPerformed(OpenMoviment.java:403)
at com.t2tierp.pafecf.view.OpenMoviment.access$200(OpenMoviment.java:22)
at com.t2tierp.pafecf.view.OpenMoviment$4.actionPerformed(OpenMoviment.java:240)
at javax.swing.JTextField.fireActionPerformed(Unknown Source)
at javax.swing.JTextField.postActionEvent(Unknown Source)
at javax.swing.JTextField$NotifyAction.actionPerformed(Unknown Source)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
at com.t2tierp.pafecf.view.Caixa.verificarMovimentoExistente(Caixa.java:3392)
at com.t2tierp.pafecf.view.Caixa.<init>(Caixa.java:344)
at com.t2tierp.pafecf.view.Caixa$41.run(Caixa.java:2393)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
我怎樣才能讓我的方法真的叫代替原來的方法是什麼?
你打算用'Boolean'來實現什麼? – Blasanka
雖然你的問題在我眼中是好的,這真的有必要嗎? 你知道自動拆箱,它基本上爲你解決了這個問題嗎? (它使得它如此,如果你調用原始函數但是使用布爾參數,它在將參數傳遞給方法之前基本上調用參數'Boolean#booleanValue()')。 – Buurman
我看到你正在使用包裝類 - 布爾在你的覆蓋方法第二個參數,這樣做的任何理由? –