I need create a report with Columns added dynamically, So i choose Dynamic Report version 5.3.2 to achieve this, but there is problem while rendering the report. i have an Exception i dont know what's wrong, it's about xml parser or something like but i don't really know. I use jdk 1.8.2.0 and Netabeans 11.0 as IDE, here is the excpetion
Exception in thread "AWT-EventQueue-0" java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.<init>(SimpleFontExtensionHelper.java:149)
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.getInstance(SimpleFontExtensionHelper.java:131)
at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.ensureFontExtensions(FontExtensionsRegistry.java:80)
at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.getExtensions(FontExtensionsRegistry.java:57)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:134)
at net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:86)
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:114)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:82)
at net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:251)
at net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:272)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:156)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:145)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:758)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:1074)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:244)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:220)
at com.gepa.views.principal.PrincipalScreenx.rapportPerformanceActionAction(PrincipalScreenx.java:6307)
at com.gepa.views.principal.PrincipalScreenx$85.actionPerformed(PrincipalScreenx.java:3166)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2739)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:719)
at java.awt.EventQueue$4.run(EventQueue.java:717)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
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)
Here is my code for creating the dynamic report
FastReportBuilder drb = new FastReportBuilder();
drb.addColumn("State", "state", String.class.getName(),30)
.addColumn("Branch", "branch", String.class.getName(),30)
.addColumn("Product Line", "productLine", String.class.getName(),50)
.addColumn("Item", "item", String.class.getName(),50)
.addColumn("Item Code", "id", Long.class.getName(),30,true)
.addColumn("Quantity", "quantity", Long.class.getName(),60,true)
.addColumn("Amount", "amount", Float.class.getName(),70,true)
.addGroups(2)
.setTitle("November " + 2021 +" sales report")
.setSubtitle("This report was generated at " + new Date())
.setPrintBackgroundOnOddRows(true)
.setUseFullPageWidth(true);
drb.addGlobalFooterVariable(drb.getColumn(4), DJCalculation.COUNT, null, new DJValueFormatter() {
public String getClassName() {
return String.class.getName();
}
public Object evaluate(Object value, Map fields, Map variables, Map parameters) {
return (value == null ? "0" : value.toString()) + " Clients";
}
});
List rowsDataList = new ArrayList();
DynamicReport dr = drb.build();
JasperPrint finalreport = DynamicJasperHelper.generateJasperPrint(dr,new ClassicLayoutManager(), rowsDataList);
JasperViewer.viewReport(finalreport);
}catch(Exception e)
{
e.printStackTrace();
}
I don't know if it's cause by a missing dependancy or a conflict but it's not working, Please help me to solve this. Thanks in advance
looks like your project is using a old version of the JAXP (Locate and uninstall the plugin that loads the outdated implementation of the Java API for XML Processing (JAXP), e.g., Xerces 2.6.)
I found this info that might help: https://support.cloudbees.com/hc/en-us/articles/360036082251-Pipeline-Maven-Integration-fails-due-to-java-lang-AbstractMethodError?page=21
Related
I found problems after applying some code to different parts of my program written in Java.
These problems can be seen in several sections: deleting data from the database, updating database information and search, but the search was added later, and I think the problem is the code of the update section or the display of data.
Other sections work like adding to the database
public void showTableData(){
try
{
Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
String database="jdbc:mysql://localhost:3307/tigernew?user=root";
Connection connect=DriverManager.getConnection(database);
Statement state=connect.createStatement();
String query="SELECT * FROM `user` WHERE 1";
ResultSet result=state.executeQuery(query);
DefaultTableModel dm=(DefaultTableModel) tbl_show.getModel();
int rowCount=dm.getRowCount();
for(int i=rowCount -1;i>=0;i--){
dm.removeRow(i);
}
while(result.next()){
int id=result.getInt(1);
String name=result.getString(2);
String family=result.getString(3);
String email=result.getString(4);
String site=result.getString(5);
Object[] content ={id,name,family,email,site} ;
DefaultTableModel model=(DefaultTableModel) tbl_show.getModel();
model.addRow(content);
}
state.close();
connect.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void btn_data_updateActionPerformed(java.awt.event.ActionEvent evt) {
try
{
int id=Integer.parseInt(rowId);
Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
String database="jdbc:mysql://localhost:3307/tigernew?user=root";
Connection connect=DriverManager.getConnection(database);
Statement state=connect.createStatement();
String query="UPDATE `user` SET `name`='[%s]',`family`='[%s]',`email`='[%s]',`site`='[%s]' WHERE 1";
query=String.format(query,txt_name_update.getText(),txt_family_update.getText(),txt_email_update.getText(),txt_site_update.getText(),id);
state.execute(query);
state.close();
connect.close();
txt_name_update.setText("");
txt_family_update.setText("");
txt_email_update.setText("");
txt_site_update.setText("");
showTableData();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
try
{
String param=cmb_param_srch.getSelectedItem().toString();
String data=txt_data_srch.getText();
Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
String database="jdbc:mysql://localhost:3307/tigernew?user=root";
Connection connect=DriverManager.getConnection(database);
Statement state=connect.createStatement();
String query="SELECT * FROM `user` WHERE %s='%s'";
query=String.format(query,param,data);
ResultSet result=state.executeQuery(query);
DefaultTableModel dm=(DefaultTableModel) tbl_show.getModel();
int rowCount=dm.getRowCount();
for(int i=rowCount -1;i>=0;i--){
dm.removeRow(i);
}
while(result.next()){
int id=result.getInt(1);
String name=result.getString(2);
String family=result.getString(3);
String email=result.getString(4);
String site=result.getString(5);
Object[] content ={id,name,family,email,site} ;
DefaultTableModel model=(DefaultTableModel) tbl_show.getModel();
model.addRow(content);
}
state.close();
connect.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void btn_deleteActionPerformed(java.awt.event.ActionEvent evt) {
try
{
int id=Integer.parseInt(rowId);
Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
String database="jdbc:mysql://localhost:3307/tigernew?user=root";
Connection connect=DriverManager.getConnection(database);
Statement state=connect.createStatement();
String query="DELETE FROM `user` WHERE id=%s";
query=String.format(query,id);
state.execute(query);
state.close();
connect.close();
txt_id_delete.setText("");
}
catch (Exception e)
{
e.printStackTrace();
}
}
I was able to fix the list display feature in the table, but the delete and update feature does not work. This error is related to the delete section:
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:542)
at java.lang.Integer.parseInt(Integer.java:615)
at mySQL.Main.btn_deleteActionPerformed(Main.java:630)
at mySQL.Main.access$1200(Main.java:15)
at mySQL.Main$14.actionPerformed(Main.java:398)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
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:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
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)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 5 >= 5
at java.util.Vector.elementAt(Vector.java:474)
at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:649)
at mySQL.Main.tbl_showMouseClicked(Main.java:713)
at mySQL.Main.access$900(Main.java:15)
at mySQL.Main$11.mouseClicked(Main.java:336)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
at java.awt.Component.processMouseEvent(Component.java:6528)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4542)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
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)
java.lang.NumberFormatException: For input string: "[s]"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at mySQL.Main.btn_data_updateActionPerformed(Main.java:683)
at mySQL.Main.access$700(Main.java:15)
at mySQL.Main$8.actionPerformed(Main.java:236)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
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:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
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)
java.lang.NumberFormatException: For input string: "[s]"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at mySQL.Main.btn_deleteActionPerformed(Main.java:630)
at mySQL.Main.access$1200(Main.java:15)
at mySQL.Main$14.actionPerformed(Main.java:398)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
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:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
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)
BUILD SUCCESSFUL (total time: 37 seconds)
Thank you for your help
I've centos6.4 in both server and client in VM. I'm trying to store some values (jTextFieldBookID.getText(), jTextFieldBookName.getText(), jTextFieldCategory.getText(), jTextAreaDescription.getText(), and sqdate.) in oracle 11gr2 from java (java SE 8). but having hundreds of errors. I am not getting the solution.
code is:
tablebookmaster:-
SQL> desc tablebookmaster;
Name Null? Type
----------------------------------------- -------- ----------------------------
BOOKID NOT NULL NUMBER(38)
BOOKNAME VARCHAR2(45)
CATEGORY VARCHAR2(30)
DESCRIPTION VARCHAR2(60)
REGISTRYDATE DATE
ClassConnectDB file:
package PackageInventory;
import java.sql.*;
import javax.swing.JOptionPane;
public class ClassConnectDB
{
public static Connection connectdb()
{
try
{
Connection conn = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:#serverora11gr2:1521:orcl","scott","tiger");
return conn;
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, " exception in ClassConnectDB.connectdb() is : " + e);
return null;
}
}
}
file jFrameBookMaster:
import java.sql.*;
//import java.sql.Date;
import javax.swing.JOptionPane;
import javax.swing.*;
import java.text.*;
import java.util.*;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt)
{
//Date date = jDateChooserRegistryDate.getDate();
try
{
//conn = ClassConnectDB.connectdb();
conn = ClassConnectDB.connectdb();
String JTextfieldBookIdStr = jTextFieldBookID.getText();
String JTextFieldBooknameStr = jTextFieldBookName.getText();
String JTexTFieldCategoryStr = jTextFieldCategory.getText();
String JtextAeraDesciptionStr = jTextAreaDescription.getText();
java.util.Date udate = new java.util.Date();
udate = jXDatePickerRegistryDate.getDate();
udate = jXDatePickerRegistryDate.getDate();
java.sql.Date sqdate = new java.sql.Date(udate.getTime());
//sqdate = new java.sql.Date(udate.getTime());
String sql = "insert into tablebookmaster values(?, ?, ?, ?, ?);";
pst = conn.prepareStatement(sql);
pst.setInt(1, Integer.parseInt(JTextfieldBookIdStr) );
//JOptionPane.showMessageDialog(null,"
pst.setString(2,JTextFieldBooknameStr);
pst.setString(3,JTexTFieldCategoryStr);
pst.setString(4,JtextAeraDesciptionStr);
pst.setDate(5, sqdate);
pst = conn.prepareStatement(sql);
int inserted = pst.executeUpdate();
if(inserted == 1)
{
JOptionPane.showMessageDialog(null,"row inserted successfully");
}
else
{
JOptionPane.showMessageDialog(null,"Sorry!. Your record has not saved");
}
conn.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, "exception in jButtonSaveActionPerformed : " + e);
}
}
The error message:
Dec 13, 2018 12:26:01 PM oracle.jdbc.driver.OracleDriver registerMBeans
WARNING: Error while registering Oracle JDBC Diagnosability MBean.
java.lang.ExceptionInInitializerError
at oracle.jdbc.driver.OracleDriver.registerMBeans(OracleDriver.java:313)
at oracle.jdbc.driver.OracleDriver$1.run(OracleDriver.java:201)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.jdbc.driver.OracleDriver.<clinit>(OracleDriver.java:197)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at PackageInventory.ClassConnectDB.connectdb(ClassConnectDB.java:17)
at PackageInventory.JFrameBookMaster.jButtonSaveActionPerformed(JFrameBookMaster.java:225)
at PackageInventory.JFrameBookMaster.access$000(JFrameBookMaster.java:26)
at PackageInventory.JFrameBookMaster$1.actionPerformed(JFrameBookMaster.java:71)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
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:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2739)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:719)
at java.awt.EventQueue$4.run(EventQueue.java:717)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
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)
Caused by: java.lang.SecurityException: sealing violation: package oracle.jdbc.internal is sealed
at java.net.URLClassLoader.getAndVerifyPackage(URLClassLoader.java:394)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:423)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:340)
at oracle.jdbc.driver.ClassRef.get(ClassRef.java:92)
at oracle.jdbc.driver.ClassRef$XMLTypeClassRef.<init>(ClassRef.java:120)
at oracle.jdbc.driver.ClassRef$XMLTypeClassRef.newInstance(ClassRef.java:109)
at oracle.jdbc.driver.ClassRef.<clinit>(ClassRef.java:42)
... 46 more
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Could not initialize class
oracle.jdbc.driver.ClassRef
at oracle.jdbc.driver.OracleDriver.<clinit>(OracleDriver.java:262)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at PackageInventory.ClassConnectDB.connectdb(ClassConnectDB.java:17)
at PackageInventory.JFrameBookMaster.jButtonSaveActionPerformed(JFrameBookMaster.java:225)
at PackageInventory.JFrameBookMaster.access$000(JFrameBookMaster.java:26)
at PackageInventory.JFrameBookMaster$1.actionPerformed(JFrameBookMaster.java:71)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
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:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2739)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:719)
at java.awt.EventQueue$4.run(EventQueue.java:717)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
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)
I have created a method using JFreeChart and SQL that essentially creates a graph based on the data present in the database. I have 3 methods, one particular example, the users weight vs time. I wish to display these graphs in a JTabbedPane and am unsure how. When I call the method on the one tab it tells me static/void methods are not allowed. My method has no paramters. Here is my initial attempt:
panelWeight = new JPanel();
panelWeight.setLayout(null);
panelWeight.add(StatGraph.WeightGraph());
EDIT:
I returned to the drawing board, after discovering a) I cannot call a void method to the component and B) a null layout does not scale. Here is my re-written method I wish to call to the JTabbedPane, making the method non-void.
public static ChartFrame WeightGraph(){
ChartFrame returnFrame = null;
try{
ConnectionManager connectionManager = ConnectionManager.getInstance();
Connection connection = connectionManager.getConnection();
UserInfoManager user = new UserInfoManager();
int username = user.getId();
String query = "SELECT DATE, WEIGHT FROM STATS WHERE ID=" + username; JDBCCategoryDataset dataset = new JDBCCategoryDataset(connection, query);
JFreeChart chart = ChartFactory.createLineChart("WEIGHTvsDATE Chart", "Date", "Weight", dataset, PlotOrientation.VERTICAL, false, true, true);
BarRenderer renderer = null;
CategoryPlot plot = null;
renderer = new BarRenderer();
ChartFrame frame = new ChartFrame("Progress Log", chart);
returnFrame = frame;
//frame.setVisible(true);
//frame.setSize(750,400);
}
catch(Exception e){
JOptionPane.showMessageDialog(null,e);
}
return returnFrame;
}
I then return to the GUI Frame and add the following code to the Panel in the TabbedPane, activated by using a click listener.
panelWeight.add(StatGraph.WeightGraph());
However, I get the following error:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: adding a window to a container
at java.awt.Container.checkNotAWindow(Container.java:488)
at java.awt.Container.addImpl(Container.java:1089)
at java.awt.Container.add(Container.java:415)
at GUI.PT.ProgressStatsPT.panelWeightMouseClicked(ProgressStatsPT.java:392)
at GUI.PT.ProgressStatsPT.access$600(ProgressStatsPT.java:26)
at GUI.PT.ProgressStatsPT$7.mouseClicked(ProgressStatsPT.java:138)
at java.awt.Component.processMouseEvent(Component.java:6528)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4542)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
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)
What does exactly Graph.weightLg() return? The add() method from JPanel takes an instance of Component or a subclass. If the Graph.weightLg() method doesn't return anything (which I suppose is your case) the compilation will fail.
I have a program where you can input name, surname, id and export them to a text file. The file can be imported back by using a load method. The problem with the load method is if you press the load button and don't select a file the list of errors will appear. I need to create an exception for these errors so the user will receive "Please Select a file" warning instead. So I created a custom exception:
public class CancelException extends Exception {
public CancelException() {
}
public CancelException(String message) {
super(message);
}
}
Then I tried to put it in the load method:
public static Person loadcons() throws IOException, CancelException {
Person loadcons = null;
try {
JFileChooser chooser = new JFileChooser();
int chooserOption = chooser.showSaveDialog(null);
chooserOption = JFileChooser.APPROVE_OPTION;
File file = new File(chooser.getSelectedFile().getAbsolutePath());
ObjectInputStream input = new ObjectInputStream(new FileInputStream(file));
loadcons = (Person) input.readObject();
input.close();
return loadcons;
} catch (IOException ex) {
System.out.println(ex.getMessage());
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
} catch (Exception ex) {
throw new CancelException("Please select a file");
}
return null;
}
private String toString(String PersonID) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
The problem is that the exception is not being recognized and it is still giving me the exception stack trace instead of the warning.
The list of errors are below:
Aug 17, 2015 12:41:50 PM ryan_assignment_sit2.CreateConsultant jButton3ActionPerformed
SEVERE: null
ryan_assignment_sit2.CancelException: Please select a file
at ryan_assignment_sit2.Person.loadcons(Person.java:105)
at ryan_assignment_sit2.CreateConsultant.jButton3ActionPerformed(CreateConsultant.java:218)
at ryan_assignment_sit2.CreateConsultant.access$300(CreateConsultant.java:29)
at ryan_assignment_sit2.CreateConsultant$4.actionPerformed(CreateConsultant.java:87)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
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:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.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$1.doIntersectionPrivilege(ProtectionDomain.java:75)
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)
You can just check whether the file is selected or not by adding following condition:
if (chooser.getSelectedFile() == null)
{
JOptionPane.showMessageDialog(null, "Please select a file", "No file selected", JOptionPane.WARNING_MESSAGE);
}
null ryan_assignment_sit2.CancelException: Please select a file at ryan_assignment_sit2.Person.loadcons(Person.java:105) at
Isn't it throwing an exception ? because you have passed the message to super class which is exception class.
you can try it just printing the warning using JOption pane instead?
I used the java prepared statement in a try-with-resources statement to access a table
in the Java DB database with NetBeans 8.0 IDE. After running the executeUpdate method ,
I then runned the generated keys method to retrieve all auto generated values.
However the generated keys resultset gives a null point error. The table has
an auto generated primary key.
the code snippet is presented below.
try (Connection con = DriverManager.getConnection(host, uName, uPass)) {
con.setAutoCommit(false); //disable auto commit
try( PreparedStatement stmAlumnus = con.prepareStatement(insertSQL)) {
stmAlumnus.setInt(1, Integer.parseInt(id_TextField.getText().trim()));
stmAlumnus.setString(2, fName_TextField.getText().toUpperCase().trim());
stmAlumnus.setString(3, lName_TextField.getText().toUpperCase().trim());
stmAlumnus.setString(4, oName_TextField.getText().toUpperCase().trim());
stmAlumnus.setInt(5, year_ComboBox.getSelectedIndex());
stmAlumnus.setBoolean(6,employeedRadioButton.isSelected());
stmAlumnus.setString(7, jTitle_TextField.getText().toUpperCase().trim());
stmAlumnus.setString(8, email_TextField.getText().toUpperCase().trim());
stmAlumnus.setString(9, tel_TextField.getText().toUpperCase().trim());
stmAlumnus.executeUpdate();
ResultSet rst = stmAlumnus.getGeneratedKeys();
863
864 while(rst.next())
865 {System.out.println("this is the ID" + rst.getNString(1));}
866 } //close prepared statement
con.commit();
} //close connection
catch (SQLException ex)
{
if (con != null) {
try {
System.err.print("Transaction is being rolled back");
con.rollback();
} catch(SQLException excep) {
excep.printStackTrace();
}
Logger.getLogger(MyJFrame.class.getName()).log(Level.SEVERE, null, ex);
ex.getSuppressed();
}
}
}
below is the error message from the NetBeans IDE
run:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at wa_poly.MyJFrame.insertIntoTables(MyJFrame.java:864)
at wa_poly.MyJFrame.saveButtonActionPerformed(MyJFrame.java:653)
at wa_poly.MyJFrame.access$700(MyJFrame.java:41)
at wa_poly.MyJFrame$8.actionPerformed(MyJFrame.java:524)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
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:6527)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6292)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4883)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4705)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2739)
at java.awt.Component.dispatchEvent(Component.java:4705)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:746)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:719)
at java.awt.EventQueue$4.run(EventQueue.java:717)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:716)
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)
Suppressed: java.sql.SQLException: Cannot close a connection while a transaction is still active.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.checkForTransactionInProgress(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.close(Unknown Source)
at wa_poly.MyJFrame.insertIntoTables(MyJFrame.java:886)
... 39 more
Caused by: java.sql.SQLException: Cannot close a connection while a transaction is still active.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)
... 47 more
Is there an explanation for the error produced.
When you prepare the statement, you have to use a flag.
e.g.
ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);