4 Replies Latest reply on May 1, 2014 10:20 AM by Claus Ibsen

    mysql jdbc connection setup issue

    neo anderson Newbie

      Hi All ,

      I have put a bean about mysql connection in my camleContext.xml  :

      <bean id="databaseConnection" class="org.springframework.jdbc.datasource.DriverManagerDataSource">

        <property name="driverClassName" value="com.mysql.jdbc.Driver" />

        <property name="url" value="jdbc:mysql://localhost:3306/employees" />

        <property name="username" value="root" />

        <property name="password" value="abc123@" />

        </bean>

       

      when i run the xml with no test , i got some error message :

      [ERROR] *************************************

      [ERROR] Error occurred while running main from: org.apache.camel.spring.Main

      [ERROR]

      java.lang.reflect.InvocationTargetException

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:606)

        at org.apache.camel.maven.RunMojo$1.run(RunMojo.java:487)

        at java.lang.Thread.run(Thread.java:744)

      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'databaseConnection' defined in file [/home/neo/jbdevstudio/workspace/camel-amq/target/classes/META-INF/spring/camelListner.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:

      PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver]

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1453)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1158)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)

        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)

        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)

        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)

        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)

        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)

        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)

        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)

        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)

        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)

        at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:186)

        at org.apache.camel.spring.Main.doStart(Main.java:140)

        at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)

        at org.apache.camel.main.MainSupport.run(MainSupport.java:148)

        at org.apache.camel.main.MainSupport.run(MainSupport.java:352)

        at org.apache.camel.spring.Main.main(Main.java:73)

        ... 6 more

      Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:

      PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver]

        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:101)

        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1450)

        ... 24 more

      [ERROR] *************************************

       

      How can I resolve this exception ?

      Thanks ,

      Best regards.