I encountered the following error when I was executing my application:
java.sql.SQLException: No value specified for parameter 1
What does it mean?
My UserGroup
list in my dao:
public List<UsuariousGrupos> select(Integer var) {
List<UsuariousGrupos> ug= null;
try {
conn.Connection();
stmt = conn.getPreparedStatement("select id_usuario, id_grupo from usuarios_grupos where id_grupo ='" + var + "'");
ResultSet rs = stmt.executeQuery();
ug = new ArrayList<UsuariousGrupos>();
while (rs.next()) {
ug.add(getUserGrupos(rs));
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
conn.Disconnected();
}
return ug;
}
public UsuariousGrupos getUserGrupos(ResultSet rs) {
try {
UsuariousGrupos ug = new UsuariousGrupos(rs.getInt("id_usuario"), rs.getInt("id_grupo"));
return ug;
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
My get list of User groups in my managed bean:
public List<UsuariousGrupos> getListOfUserGroups() {
List<UsuariousGrupos> usuariosGruposList = userGrpDAO.select(var2);
listOfUserGroups = usuariosGruposList;
return listOfUserGroups;
}
My JSF page:
<p:dataTable var="usergroups" value="#{usuariousGruposBean.listOfUserGroups}">
<p:column headerText="" style="height: 0" rendered="false">
<h:outputText value="#{usergroups.id_grupo}"/>
</p:column>
My data table is able to display the list of groups from the database. However, when I select an individual row within my data table, it takes some time for the application to establish connection with my database to display the selected result.
Also, it is weird that the application is able to display certain selected results quicker than others. Does it have anything to do with the Exception I pointed out at the beginning?
Error:
Disconnected
Connected!!
java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
at com.mysql.jdbc.PreparedStatement.checkAllParametersSet(PreparedStatement.java:2560)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2536)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2462)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2216)
at br.dao.UsuariousGruposDAO.select(UsuariousGruposDAO.java:126)
at br.view.UsuariousGruposBean.getListOfUserGroups(UsuariousGruposBean.java:54)
SEVERE: Error Rendering View[/index.xhtml]
javax.el.ELException: /index.xhtml @61,99 value="#{usuariousGruposBean.listOfUserGroups}": Error reading 'listOfUserGroups' on type br.view.UsuariousGruposBean
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…