• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

BeanCreationException

 
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Employee.java


EmployeeDAO.java


EmployeeDriver.java


applicationContext.xml


I'm getting bean creation exception. I believe the problem can be in xml file since I changed the configuration from Oracle 10g to mysql.
Please suggest.

Thanks
 
Marshal
Posts: 5326
324
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to be a bit more specific than that. What's the actual exception?

I suspect, though, that you don't have the jar on your class path that contains com.mysql.jdbc.Driver. I don't know off hand what jar that would be though.
 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.. I added the jar.
Now I'm stuck on this exception -
exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [insert into employee values(1,Shubham,100000.0)]; nested exception is com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'Shubham' in 'field list'
 
Master Rancher
Posts: 4189
57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the SQL given with the error message:

What happens if you run this in a SQL client?  Does it work?  If not, what changes would you need to make to fix this?

There's a quick fix for the code you've shown, but more generally, it's probably a good idea to use a PreparedStatement for this.  Since you're using Spring's jdbcTemplate, this functionality is found in the 3-arg version of update(), not the single-arg version that you used.  See example here - the part about

 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks got it. It was expecting the varchar shubham as 'shubham'. I made the changes and now it works fine
 
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic