Bug #91299 createStatement() method gaves me a NullPointerException
Submitted: 18 Jun 2018 12:09 Modified: 18 Jun 2018 16:56
Reporter: TOLGA DURAN Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version: OS:Windows
Assigned to: CPU Architecture:x86
Tags: MySQL, NullPointerException, statement

[18 Jun 2018 12:09] TOLGA DURAN
Description:
package com.tolgaduran.jdbc;

import java.sql.*;

public class TestConnOracle {
    public static void main(String[] args){

        try (
                Connection conn = DBUtil.getConnection(DBSets.MYSQL);
                Statement stmt = conn.createStatement();
                ResultSet rs = stmt.executeQuery("select * from country")
        ) {
            rs.last();

            System.out.println("Total Rows: " + rs.getRow());

            System.out.println("Connection Successfully Established as ORACLE");
        } catch (SQLException e) {
            DBUtil.getMsg(e);
        }
    }
}

How to repeat:
Exception in thread "main" java.lang.NullPointerException
	at com.tolgaduran.jdbc.TestConnOracle.main(TestConnOracle.java:10)
[18 Jun 2018 13:34] Chiranjeevi Battula
Hello TOLGA DURAN,

Thank you for the bug report and testcase.
I could not repeat the reported issue at our end using with Connector / J  8.0.11 and MySQL 8.0.11 version.

Thanks,
Chiranjeevi.
[18 Jun 2018 16:56] TOLGA DURAN
I solved that problem. It has been my failure because i have forgot a return statement in my code.