• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
Sheriff
Posts: 5555
326
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: 4796
72
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic