我试图从数据库中检索电子邮件地址,但没有成功。我的代码如下:
主要的:
System.out.println(PortfolioData.getEmails(58)); //So Far Returning null
投资组合数据:
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;
}
这是我的日志文件和错误:
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 评论说我的错误日志没有显示实际的异常。所以我删除了我的错误记录和捕获。这是我现在在终端中得到的内容:
[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)
查询本身在 MySQL Workbench 中执行良好:
DBEasyQuery 的一些附加支持代码可以在下图中找到。我从帖子中删除了它,因为它使帖子很长:http: //i.stack.imgur.com/WZDkL.png
我认为它没有错误,因为它适用于我可以扔给它的所有其他东西: