Informix driver riddle



  • When writing an app, i ran into this nice exception message thrown by the driver of an informix database.

    Makes me wonder, was it not easier to write the correct message right away?

    java.sql.SQLException: Message text will be provided in later releases java.lang.IndexOutOfBoundsException
        at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:448)
        at com.informix.jdbc.IfxSqliConnect.<init>(IfxSqliConnect.java:1034)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at com.informix.jdbc.IfxDriver.connect(IfxDriver.java:253)
        at java.sql.DriverManager.getConnection(DriverManager.java:512)
        at java.sql.DriverManager.getConnection(DriverManager.java:171)
        at com.[compname].unloadImporter.databaseHandling.InformixHandler.connect(InformixHandler.java:121)
        at com.[compname].informixExporter.InformixExporter.runExport(InformixExporter.java:158)
        at com.[compname].informixExporter.InformixExporter.run(InformixExporter.java:121)
        at java.lang.Thread.run(Thread.java:534)

    Ps. the java.lang.IndexOutOfBoundsException makes no sense, here is the code i wrote that throws the exception:

        public boolean connect() throws SQLException{
            con = null;
            try {
                Class.forName(this.databaseDriver).newInstance();
            } catch (Exception e) {
                throw new SQLException("Unable to load JDBC Driver");
            }       
            try {
                con = DriverManager.getConnection(this.connectionURL,
                                                  this.username,
                                                  this.password);
            } catch (Exception e) {

             //thrown here
                throw new SQLException("Unable to make a connection to informix database:\n\t" + e.getMessage());
            }        

          ..etc..



  • I think the IndexOutOfBoundsExceptions happens internally in the JDBC driver, maybe because there is a typo in the connectionURL.



  • Given the quality of the message, I wouldn't be at all surprised if the index out of bounds exception is valid; it may be that the driver is failing to connect to the db, carrying on regardless, failing to retrieve some properties from it, carrying on anyway, then catching the IndexOutOfBoundsException when iterating over an array that's smaller than the code was expecting (ie empty).



  • @i1emming said:

    When writing an app, i ran into this nice exception message thrown by the driver of an informix database.

    Makes me wonder, was it not easier to write the correct message right away?

    I'd bet that they have something like

    try{

    //hundreds of lines of code where many different types of exceptions can occur on multiple lines
     

    }

    catch(IndexOutOfBoundsException E){

    //What actually caused the exception? 

    throw E; 

    catch(NullPointerException E){

    //what actually caused the exception?

    }

    etc...
    So when they catch the exception they don't know what the actual cause is. 



  • @bonzombiekitty said:


    So when they catch the exception they don't know what the actual cause is. 

    Could be as simple as that:

    String[] params = url.split(";")[0].split(":");

    String protocol = params[0];
    String driver = params[1];
    String host = params[2];
    String port = params[3];
    String instance = params[4];

     

     

     

     



  • @ammoQ said:

    Could be as simple as that:

    Yeah, but I was more reffering to why they didn't give a more informative error when they went through the trouble to say that the error message will be included in later versions.  In the case you posted, you could say something like "url paramater is not of the correct form" or something like that, which takes just as much effort to say as "message text will be included in later versions".   But if the error came out of a much larger block of code, then you don't know what the error the reason for the error is, hence the message saying it will be included in later versions. 
     



  • Wouldn't entirely surprise me if there were a bureaucratic WTF behind this.  Maybe the error messages have to be approved by some department or committee to make sure they're clear, spelled correctly, etc., and for some reason they released before that happened? 



  • @bonzombiekitty said:

    Yeah, but I was more reffering to why they didn't give a more informative error when they went through the trouble to say that the error message will be included in later versions.  In the case you posted, you could say something like "url paramater is not of the correct form" or something like that, which takes just as much effort to say as "message text will be included in later versions".   But if the error came out of a much larger block of code, then you don't know what the error the reason for the error is, hence the message saying it will be included in later versions.

    Maybe com.informix.util.IfxErrMsg.getSQLException does a big switch on all the various error codes, with "message text will be included in later versions" being the default? 

    If you submit a bug report on it, they'll find out what really happened in this particular instance and add it to the switch before their next release.
     


Log in to reply