• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

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: 5508
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'
 
Rancher
Posts: 4358
59
  • 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