Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed Feb 08, 2023 8:03 am

Dear Support,

I have a NumberFormatException: For input string: ""
when I try resultset to datatable with jdbc adapter when the query inside some null value
Code: Select all
stmt.execute(sql);
resultSet = stmt.getResultSet();

Workbook workbook = new Workbook();
JdbcAdapter jdbcAdapter = new JdbcAdapter();
jdbcAdapter.fillDataTable(datatable, resultSet);

The code run fine when querry don't have null value.
What make I wrong?

Vizinyenyec
 
Posts: 15
Joined: Mon May 09, 2022 10:16 am

Wed Feb 08, 2023 10:01 am

Hello,

Thanks for your inquiry.
Are you using the latest version of Spire.Xls 13.1.3? If not, please update to it and test again. If the issue still exists after updating to the latest version, please offer the test java project the can reproduce your issue, if the test java project is big, you could upload your large file via Dropbox or OneDrive server, then share us with the download link. And please offer your jdk version, such as Oracle Jdk1.8.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Thu Feb 09, 2023 8:04 am

null value.jpg
null value.jpg (27.8 KiB) Viewed 1264 times
Hy

I update the latest version, but I have the problem even now.
My code:
Code: Select all
public void vevoi_lekerdezes_excel(String projekt, String datumtol, String datumig, String lezart, String nyitott)
    {
        Connection conn = null;
        Statement stmt = null;
        DataTable datatable = new DataTable();
        try
        {
           try
           {
              Class.forName("com.mysql.cj.jdbc.Driver");
           }
           catch (Exception e)
           {
              System.out.println(e);
              String hibauzenet2 = e.toString();
              JOptionPane.showMessageDialog(null, hibauzenet2, "Hiba üzenet", 2);
           }
        conn = DriverManager.getConnection("jdbc:mysql://172.20.22.29", "veasquality", "kg6T$kd14TWbs9&gd");
        stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
        String sql = "";

        if(projekt.equals("-"))
        {
            projekt = "%";
        }
       
        if(lezart.equals("igen") && nyitott.equals("igen"))
        {
            sql = "SELECT * FROM  qualitydb.Vevoireklamacio_alapadat where Projekt like '"+ projekt +"' and Datum >= '"+ datumtol
                            +"' and Datum <= '"+ datumig +"'";
        }
        else if(lezart.equals("igen") && nyitott.equals("nem"))
        {
            sql = "SELECT DATE_FORMAT(Datum,'%Y%m'), projekt, rek_vagy, nyitva FROM  qualitydb.Vevoireklamacio_alapadat where Projekt like '"+ projekt +"' and Datum >= '"+ datumtol
                            +"' and Datum <= '"+ datumig +"' and Lezaras_ido is not null  group by Projekt";
        }
        else
        {
            sql = "SELECT * FROM  qualitydb.Vevoireklamacio_alapadat where Projekt like '"+ projekt +"' and Datum >= '"+ datumtol
                    +"' and Datum <= '"+ datumig +"' and Lezaras_ido is null  ";
        }
        stmt.execute(sql);
        resultSet = stmt.getResultSet();

        Workbook workbook = new Workbook();
        JdbcAdapter jdbcAdapter = new JdbcAdapter();
        jdbcAdapter.fillDataTable(datatable, resultSet);                    //  <= Here is the Exception

        //Get the first worksheet
        Worksheet sheet = workbook.getWorksheets().get(0);
        sheet.insertDataTable(datatable, true, 1, 1);
JFileChooser mentes_helye = new JFileChooser();
        mentes_helye.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        mentes_helye.showOpenDialog(mentes_helye);
        File fajl = mentes_helye.getSelectedFile();
        //System.out.println(fajl.getAbsolutePath());
        workbook.saveToFile(fajl.getAbsolutePath(), ExcelVersion.Version2016);
        resultSet.close();
        stmt.close();
        conn.close();


And this is the exception:
java.lang.NumberFormatException: For input string: ""
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
at java.base/java.lang.Integer.parseInt(Integer.java:678)
at java.base/java.lang.Integer.valueOf(Integer.java:999)
at com.spire.xls.packages.sprqzba.spr▋╸(Unknown Source)
at com.spire.xls.packages.sprqzba.spr┾╸(Unknown Source)
at com.spire.data.table.DataColumn.spr┾╸(Unknown Source)
at com.spire.data.table.DataRow.setObject(Unknown Source)
at com.spire.data.table.common.JdbcAdapter.fillDataTable(Unknown Source)
at com.spire.data.table.common.JdbcAdapter.fillDataTable(Unknown Source)
at SQL.vevoi_lekerdezes_excel(SQL.java:755)

And this is the data base:
null value.jpg
null value.jpg (27.8 KiB) Viewed 1264 times

Vizinyenyec
 
Posts: 15
Joined: Mon May 09, 2022 10:16 am

Thu Feb 09, 2023 11:11 am

Hello,

Thanks for your feedback.
I'll give you feedback asap after investigation.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Thu Feb 09, 2023 11:17 am

Hi

Thanks in advance!

Vizinyenyec

Vizinyenyec
 
Posts: 15
Joined: Mon May 09, 2022 10:16 am

Fri Feb 10, 2023 10:23 am

Hello,

Thanks for your feedback.
I reproduced your issue and logged it into our bug tracking system with the ticket number SPIREXLS-4461. Our development team will do further investigate. Once there are any updates, I will inform you in time. Sorry for the inconvenience caused.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Mon Mar 13, 2023 2:31 am

Hello,

Thanks for your patience!
Glad to inform you that we just released Spire.Xls13.3.1 which fixes the issue with SPIREXLS-4461.
Please download the new version from the following links to test.
Website download link: https://www.e-iceblue.com/Download/xls-for-java.html

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Tue Mar 21, 2023 7:25 am

Hello Team!

It's work fine.
Thanx for the Help.
You are awsome!

Best Regards
Vizinyenyec

Vizinyenyec
 
Posts: 15
Joined: Mon May 09, 2022 10:16 am

Tue Mar 21, 2023 7:53 am

Hello,

Thanks for your feedback.
If you have any issue in the future, just feel free to contact us.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.XLS