Can we see how you set parameters for this prepared statement?
2009/5/25, Gurvan Le Guernic <[email protected]>: > Hi, > I have a java.lang.NullPointerException when preparing the following > statement: > > SELECT method, COUNT(method) FROM methodParameters INNER JOIN types > ON parameter = id WHERE name IN (?) GROUP BY method HAVING COUNT(method) > >= ? > > with the command: dbConnection.prepareStatement(sqlStr); > > The tables involved are: > "CREATE TABLE types (" + > " id INT PRIMARY KEY GENERATED ALWAYS AS IDENTITY," + > " name VARCHAR(128) NOT NULL UNIQUE," + > " shortName VARCHAR(64) NOT NULL" + > ")" > and > "CREATE TABLE methodParameters (" + > " method INT REFERENCES methods (id)," + > " position INT," + > " parameter INT REFERENCES types (id)" + > ")" > > SQL information for the exception are: > SQL state: XJ001 > Error code: 0 > > And the stack trace is: > Message: Exception Java : ': java.lang.NullPointerException'. > java.sql.SQLException: Exception Java : ': java.lang.NullPointerException'. > at > org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown > Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown > Source) > at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source) > at > org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown > Source) > at > org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown > Source) > at > org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source) > at > org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source) > at > org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(Unknown Source) > at > org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(Unknown Source) > at > org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(Unknown Source) > at > org.apache.derby.impl.jdbc.EmbedPreparedStatement40.<init>(Unknown Source) > at > org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source) > at > org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source) > at > org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown Source) > at org.thinkcollabs.jmbrowser.db.DAO.initSelect(DAO.java:370) > at > org.thinkcollabs.jmbrowser.db.DB_Derby$MethodDataLoader.run(DB_Derby.java:254) > Caused by: java.sql.SQLException: Exception Java : ': > java.lang.NullPointerException'. > at > org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown > Source) > at > org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown > Source) > ... 16 more > Caused by: java.lang.NullPointerException > at > org.apache.derby.impl.sql.compile.ColumnReference.remapColumnReferencesToExpressions(Unknown > Source) > at > org.apache.derby.impl.sql.compile.AggregateNode.getNewExpressionResultColumn(Unknown > Source) > at > org.apache.derby.impl.sql.compile.GroupByNode.addAggregateColumns(Unknown > Source) > at > org.apache.derby.impl.sql.compile.GroupByNode.addNewColumnsForAggregation(Unknown > Source) > at > org.apache.derby.impl.sql.compile.GroupByNode.addAggregates(Unknown Source) > at org.apache.derby.impl.sql.compile.GroupByNode.init(Unknown > Source) > at org.apache.derby.iapi.sql.compile.NodeFactory.getNode(Unknown > Source) > at > org.apache.derby.impl.sql.compile.SelectNode.genProjectRestrict(Unknown > Source) > at > org.apache.derby.impl.sql.compile.SelectNode.modifyAccessPaths(Unknown > Source) > at > org.apache.derby.impl.sql.compile.DMLStatementNode.optimizeStatement(Unknown > Source) > at > org.apache.derby.impl.sql.compile.CursorNode.optimizeStatement(Unknown > Source) > at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown > Source) > at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown > Source) > at > org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown > Source) > ... 9 more > > I can't see what I am doing wrong, but I am not an SQL expert. So, I am > doing something wrong or is there a problem with Derby 10.5.1.1? > > Thank you, > Gurvan >
