Hi, I am trying the example from the book "Struts For Dummies" ,

I got this error :

java.lang.NullPointerException
dummies.struts.LoginBean.validateUser(LoginBean.java:36)
dummies.struts.LoginAction.execute(LoginAction.java:26)





here is the DataSource Definition in struts-config.xml :


<data-sources>
<data-source key="musiccollection"
type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="description" value="Music Collection Database"/>
<set-property property="driverClassName" value="com.mysql.jdbc.Driver"/>
<set-property property="username" value="root"/>
<set-property property="password" value="malta122"/>
<set-property property="url"
value="jdbc:mysql://localhost/musiccollection"/>
</data-source>
</data-sources>


LoginBean.java :

[code]

package dummies.struts; import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.servlet.http.HttpServletRequest; import javax.sql.DataSource; public class LoginBean { private DataSource dataSource = null; public LoginBean(DataSource dataSource) { this.dataSource = dataSource; } /** * determine if the username/password combination are * present in the validUsers repository. * @param username * @param password * @return boolean true if valid, false otherwise */ public boolean validateUser(String username, String password) { boolean valid = false; Connection con = null; Statement stmt = null; ResultSet rs = null; try { con = dataSource.getConnection(); // line 36 stmt = con.createStatement(); rs = stmt.executeQuery( "SELECT * FROM users " + "WHERE username = '" + username + "' " + "AND password = '" + password + "'"); if (rs.next()) valid = true; } catch(SQLException e) { e.printStackTrace(); } finally { try { if (rs != null) rs.close(); } catch (SQLException e) {}; try { if (stmt != null) stmt.close(); } catch (SQLException e) {}; try { if (con != null) con.close(); } catch (SQLException e) {}; } return valid; }}

[/code]


Please tell me what this line :
con = dataSource.getConnection(); // line 36

is missing ?

thanks