• 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

BeanCreationException

 
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
  • 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: 4674
308
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
  • 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
  • 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: 3371
31
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!