• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Struts Connection pool (please help)

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :


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

is missing ?

thanks
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct me if I am wrong, but I believe it is stating that the reference to your dataSource object is NULL.



It appears that the dataSource object you pass to the LoginBean's constructor is NULL.
 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I would say the DataSource is null I think you have your url specified incorrectly. If you haven't tried this already try putting the port number after the the localhost (most likely localhost:3306 unless you have mysql running on a different port).

-Tad
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic