1

Im trying to retrieve email addresses from a database but am not having success. My Code is as Follows:

Main:

System.out.println(PortfolioData.getEmails(58));  //So Far Returning null

PortfolioData:

public static String[] getEmails(int i){    
    DebugMessage.M("Retrieving Email Records for Person Key Number: " + i);
    eq.query("SELECT EmailAddresses"
            + " FROM Emails as E"
            + " JOIN People AS P ON E.PersonKey = P.PersonKey"
            + " WHERE P.PersonKey = ?",i);
    return (String[])eq.getOnceMultipleRows("EmailAddresses");
}

DBEasyQuery:

public Object getOnceMultipleRows(String label){
    if(next()){
        try {   
            Array a = rs.getArray(label);
            String[] x = (String[])a.getArray();
            smartClose();
            return x;
            //return rs.getArray(label).getArray();
        } catch (SQLException e) {
            DebugMessage.E("getOnceMultipleRows() Failed on Query: " + queryExecuted());
            DebugMessage.E("getOnceMultiple() Failed on Label: " + label );
            notExecuted(e);
        }   
    }
    smartClose();
    return null;
}

Here is my log file and errors:

MESSAGE:   Retrieving Person Records for Person Key Number: 58
MESSAGE:   SharedConnection dziemba created
SQLQUERY:    SELECT AlphaID, FirstName, LastName, Street, City, State, Zip, Country, AcctType, SecID FROM People AS P JOIN Addresses AS A ON P.PersonKey = A.PersonKey LEFT JOIN Role AS R ON P.PersonKey = R.PersonKey WHERE P.PersonKey = 58
MESSAGE:   Retrieving Email Records for Person Key Number: 58
SQLQUERY:    SELECT EmailAddresses FROM Emails as E JOIN People AS P ON E.PersonKey = P.PersonKey WHERE P.PersonKey = 58
ERROR:   getOnceMultipleRows() Failed on Query:  SELECT EmailAddresses FROM Emails as E JOIN People AS P ON E.PersonKey = P.PersonKey WHERE P.PersonKey = 58
ERROR:   getOnceMultiple() Failed on Label: EmailAddresses
ERROR:   
 The Following Query Was NOT Executed:
 SELECT EmailAddresses FROM Emails as E JOIN People AS P ON E.PersonKey = P.PersonKey WHERE P.PersonKey = 58
 Stack Trace:
ERROR:   sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
ERROR:   sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
ERROR:   sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
ERROR:   java.lang.reflect.Constructor.newInstance(Unknown Source)
ERROR:   java.lang.Class.newInstance(Unknown Source)
ERROR:   com.mysql.jdbc.SQLError.notImplemented(SQLError.java:1334)
ERROR:   com.mysql.jdbc.ResultSetImpl.getArray(ResultSetImpl.java:1230)
ERROR:   com.mysql.jdbc.ResultSetImpl.getArray(ResultSetImpl.java:1247)
ERROR:   unl.cse.DBEasyQuery.getOnceMultipleRows(DBEasyQuery.java:218)
ERROR:   unl.cse.PortfolioData.getEmails(PortfolioData.java:136)
ERROR:   unl.cse.Main.main(Main.java:44)
ERROR:   

Kayaman commented that my error log wasn't showing the actual exception. So I've removed my error logging and catching. Here is what I'm now getting in the terminal:

[Ljava.lang.String;@59966240
java.sql.SQLFeatureNotSupportedException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at com.mysql.jdbc.SQLError.notImplemented(SQLError.java:1334)
    at com.mysql.jdbc.ResultSetImpl.getArray(ResultSetImpl.java:1230)
    at com.mysql.jdbc.ResultSetImpl.getArray(ResultSetImpl.java:1247)
    at unl.cse.DBEasyQuery.getOnceMultipleRows(DBEasyQuery.java:220)
    at unl.cse.PortfolioData.getEmails(PortfolioData.java:136)
    at unl.cse.Main.main(Main.java:44)
Exception in thread "main" java.lang.NullPointerException
    at unl.cse.DBEasyQuery.getOnceMultipleRows(DBEasyQuery.java:227)
    at unl.cse.PortfolioData.getEmails(PortfolioData.java:136)
    at unl.cse.Main.main(Main.java:44)

The query itself executes fine inside MySQL Workbench: enter image description here

Some of the additional supporting code of DBEasyQuery can be found in the below picture. I removed it from showing in the post since it makes the post really long: https://i.sstatic.net/WZDkL.png

I don't think there is an error in it since it works fine for everything else I can throw at it:

2
  • Your stacktrace seems to be missing the actual exception. That makes it quite worthless in debugging. Commented Nov 9, 2013 at 7:59
  • I just edited my post, it seems the error is: java.sql.SQLFeatureNotSupportedException Commented Nov 9, 2013 at 8:08

1 Answer 1

1

The problem is in the JDBC driver. Not all drivers support all features, and the driver you're using doesn't support this.

Solutions: find a different driver that supports the feature (if one exists).

EDIT: It doesn't look too good on the driver side. You might have to perform your queries differently.

EDIT #2: It seems that MySQL doesn't support the ARRAY type so you will need to do things in the old fashioned way.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.