JPA/Hibernate: Missing table error - mysql

I am trying to build a simple application using Hibernate JPA with MySQL but I keep getting a "Missing table" error whenever I try to deploy it to Wildfly.
My persistent class looks like this:
package com.example;
#Entity #Table
public class FooBar {
//...
}
Here is my persistence.xml:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="ExampleJPA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.example.FooBar</class>
<properties>
<!-- Configuring JDBC properties -->
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/mydatabase" />
<property name="javax.persistence.jdbc.user" value="(my user)" />
<property name="javax.persistence.jdbc.password" value="(my password)" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<!-- Hibernate properties -->
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.hbm2ddl.auto" value="validate" />
<!-- Configuring Connection Pool -->
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="500" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="2000" />
</properties>
</persistence-unit>
</persistence>
And this is the message I get when deploying to a Wildfly 8 server:
org.jboss.msc.service.StartException in service jboss.persistenceunit.\"ExampleJPA.war#ExampleJPA\": org.hibernate.HibernateException: Missing table: FooBar
Caused by: org.hibernate.HibernateException: Missing table: FooBar
I do have a table called FooBar in the database. I can access it directly with JDBC using the same url, user and password defined in the persistence.xml. What is wrong with my JPA setup?

Your table doesn't exist in the schema, so the hibernate.hbm2ddl.auto value of "validate" fails. Either create the table or change the hibernate.hbm2ddl.auto value to "create" or "update".

Related

Publishing JMS message on Solace Topic

I am facing issue while publishing JMS message on Solace server topic.
Actually we are successfully able to send message using jmsTemplate.send() method.
But unable to see the message count on solace client GUI.
Below is my solace configuration.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd">
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:messaging.properties</value>
</list>
</property>
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
</bean>
<!-- Solace Broker Configuration Details -->
<bean id="solaceJndiTemplate" class="org.springframework.jndi.JndiTemplate"
lazy-init="default" autowire="default">
<property name="environment">
<map>
<entry key="java.naming.provider.url" value="${solace.url}" />
<entry key="java.naming.factory.initial"
value="com.solacesystems.jndi.SolJNDIInitialContextFactory" />
<entry key="java.naming.security.principal" value="${solace.userName}" />
<entry key="java.naming.security.credentials" value="${solace.passWord}" />
</map>
</property>
</bean>
<bean id="solaceConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"
lazy-init="default" autowire="default">
<property name="jndiTemplate" ref="solaceJndiTemplate" />
<property name="jndiName" value="${solace.jndiName}" />
</bean>
<!-- <bean id="solaceCachedConnectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="solaceConnectionFactory" />
<property name="sessionCacheSize" value="10" />
</bean> -->
<bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="solaceJndiTemplate" />
<property name="jndiName" value="${solace.topic}" />
</bean>
<!-- <bean id="topicDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="solaceJndiTemplate" />
<property name="jndiName" value="${solace.topic}" />
</bean> -->
<bean id="solaceQueueJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="solaceConnectionFactory" />
<property name="defaultDestination" ref="destination" />
<property name="deliveryPersistent" value="false" />
<property name="explicitQosEnabled" value="true" />
<property name="pubSubDomain" value="false"/>
</bean>
<bean id="solaceTopicJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="solaceConnectionFactory" />
<property name="defaultDestination" ref="destination" />
<property name="deliveryPersistent" value="false" />
<property name="explicitQosEnabled" value="true" />
<property name="pubSubDomain" value="true"/>
</bean>
<bean id="solaceQueueBroker" class="com.isc.common.messaging.SolaceUtilityHelper">
<property name="jmsTemplate" ref="solaceQueueJmsTemplate" />
</bean>
<bean id="solaceTopicBroker" class="com.isc.common.messaging.SolaceUtilityHelper">
<property name="jmsTemplate" ref="solaceTopicJmsTemplate" />
</bean>
<bean id="messageBroker" class="com.isc.common.messaging.SolaceUtilityHelper">
<property name="activeBroker" value="${active.broker}" />
</bean>
<!-- <bean id="messageConsumer" class="com.isc.common.messaging.MessageConsumer">
</bean>
<bean id="jmsContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="solaceCachedConnectionFactory" />
<property name="destination" ref="destination" />
<property name="messageListener" ref="messageConsumer" />
</bean> -->
</beans>
please can any one suggest me solution for this.
Thanks in advance.
Saurabh Mahajan
Based on your comments, it would appear that you are publishing to a topic, but there are no endpoints configured to spool the message.
You can refer to at Adding Topic Subscriptions to Queues for details on how to configure an queue to spool messages that are published to a topic.
To confirm, you can verify whether messages are listed under the "No Subscription Match Logs". In SolAdmin, you can view them by heading to "Logging & Diagnostics" and selecting the "No Subscription Match Logs". The corresponding CLI command for this is show log no-subscription-match
Also, the statistics of your application connection would also display the number of messages received and sent, with any discard reasons. This can be viewed by heading to the "Clients" tab, and selecting the "Client" view. Then, double click on your client and head to "Statistics". Alternatively, the CLI command for this is show client <your-client-name> message-vpn <your-vpn-name> stats

Hibernate not Closing MySql Connection

I'm using C3P0 connection pool, hibernate and CDI to EntityManagerProducer
But in MySql ShowProcessList
enter image description here
My Persistence.xml
<!-- Nao remover AutoReconect=true -->
<property name="javax.persistence.jdbc.url"
value="jdbc:mysql://localhost:3307/db_simulados?autoReconnect=true" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="1994" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<!-- validate | update | create | create-drop -->
<property name="connection.useUnicode" value="true" />
<property name="connection.characterEncoding" value="uf-8" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<!-- C3P0 -->
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="connection.provider_class"
value="org.hibernate.connection.C3P0ConnectionProvider" />
<property name="hibernate.c3p0.min_size" value="1" />
<property name="hibernate.c3p0.max_size" value="5" />
<property name="hibernate.c3p0.acquire_increment" value="1" />
<property name="hibernate.c3p0.idle_test_period" value="300" />
<property name="hibernate.c3p0.max_statements" value="0" />
<property name="hibernate.c3p0.timeout" value="100" />
In my C3P0 i configure it to max 5 connection.
Why Hibernate not closing connection? with CDI the entityManager is closed normally with #disposes , but in ShowProcessList the connection not close.
My EntityManagerProducer
public class JpaUtil {
private static EntityManagerFactory emf = Persistence.createEntityManagerFactory("simuladosPU");
#Produces
#RequestScoped
public EntityManager getEntityManager() {
return emf.createEntityManager();
}
public void close(#Disposes EntityManager manager) {
// Called Normally.
System.out.println("Fechou!");
this.getEntityManager().close();
}
}
How i remove the connections and release to another user?
Don't worry. It's a desired behavior when using any database connection pool (like C3P0).
The whole idea behind connection pooling is to keep connections open and reuse them when handling subsequent requests. Because establishing a new connection to the database is a costly operation.

No suitable driver found for jdbc:mysql from tomcat 8.0

I am trying application in tomcat 8.0, but I get the error
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: No suitable driver found for jdbc:mysql://ip:3306/DURGA_DEV?characterEncoding=UTF-8
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80) ~[spring-jdbc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:630) ~[spring-jdbc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:695) ~[spring-jdbc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:727) ~[spring-jdbc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:737) ~[spring-jdbc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:787) ~[spring-jdbc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
I am using the
Tomcat 8.0.21
Spring 4.1.6
Mysql Conector : mysql-connector-java-5.1.27.jar
My context.xml file is given below.
context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd">
<bean id="datasourceProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:META-INF/config/datasource.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
<bean id="batchUpdateDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.jdbc2.optional.MysqlDataSource</value>
</property>
<property name="url">
<value>${jdbc.components.url.DURGA}</value>
</property>
<property name="username">
<value>${jdbc.components.userName.DURGA}</value>
</property>
<property name="password">
<value>${jdbc.components.password.DURGA}</value>
</property>
</bean>
<bean id="batchJDBCTemplate" class="com.nri.durga.maf.batch.MafBatchJdbcTemplate">
<constructor-arg
type="org.springframework.jdbc.datasource.DriverManagerDataSource"
ref="batchUpdateDataSource" />
</bean>
<bean id="GLOBAL"
class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
p:URL="${jdbc.components.url.GLOBAL}"
p:user="${jdbc.components.userName.GLOBAL}"
p:password="${jdbc.components.password.GLOBAL}">
</bean>
<bean id="DURGA"
class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
p:URL="${jdbc.components.url.DURGA}"
p:user="${jdbc.components.userName.DURGA}"
p:password="${jdbc.components.password.DURGA}">
</bean>
<bean id="global-tm" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="global-em" />
<property name="dataSource" ref="GLOBAL" />
</bean>
<bean id="durga-tm" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="durga-em" />
<property name="dataSource" ref="DURGA" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="false" />
<property name="databasePlatform" value="${jpa.hibernate.dialectClass}" />
</bean>
<bean id="global-em" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:packagesToScan="com.nrift.finch.*.model, com.nrift.finch.*.domain"
p:dataSource-ref="GLOBAL"
p:jpaVendorAdapter-ref="jpaVendorAdapter" />
<bean id="durga-em" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:packagesToScan="com.nri.durga.*.model, com.nri.durga.*.domain"
p:dataSource-ref="DURGA"
p:jpaVendorAdapter-ref="jpaVendorAdapter" />
</beans>
datasource.properties
jdbc.components.all=GLOBAL
# Setting for GLOBAL component
jdbc.components.url.GLOBAL=jdbc:mysql://ip:3306/DURGA_DEV
jdbc.components.userName.GLOBAL=usr
jdbc.components.password.GLOBAL=pswd
jdbc.components.minLimit.GLOBAL=1
jdbc.components.maxLimit.GLOBAL=200
jdbc.components.initialLimit.GLOBAL=1
jdbc.components.queryTimeout.GLOBAL=0
# Setting for DURGA component
jdbc.components.url.DURGA=jdbc:mysql://ip:3306/DURGA_DEV
jdbc.components.userName.DURGA=usr
jdbc.components.password.DURGA=pswd
jdbc.components.minLimit.DURGA=1
jdbc.components.maxLimit.DURGA=200
jdbc.components.initialLimit.DURGA=1
jdbc.components.queryTimeout.DURGA=0
# Datasource properties Mysql
jdbc.database.driverClass=com.mysql.jdbc.Driver
jpa.hibernate.dialectClass=org.hibernate.dialect.MySQL5Dialect
This means that your mysql driver jar is not in the classpath. Make sure that it is in "$CATALINA_HOME/lib"
I head a similar problem when deploying my application and starting Tomcat from Eclipse.
After building the war and copying it manually to the webapps folder it was working.
My setup is very much as described in this question:
java.sql.SQLException: No suitable driver
The Driver class was in Tomcat's lib folder, but it seems, my config.xml was not loaded, when deployed from Eclipse into wtpwebapps.

Liquibase Spring error: Could not instantiate bean class [liquibase.integration.spring.SpringLiquibase]

I'm trying to run liquibase changeLog using Spring, as described in docs, but i get the following error:
Could not instantiate bean class [liquibase.integration.spring.SpringLiquibase]:Constructor threw exception; nested exception is java.lang.ExceptionInInitializerError*
This is my applicationContext.xml:
<bean id="dataSourceLb" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/qacube" />
<property name="user" value="root" />
<property name="password" value="" />
<!-- c3po -->
<property name="initialPoolSize" value="5" />
<property name="autoCommitOnClose" value="false" />
<property name="idleConnectionTestPeriod" value="10" />
<property name="testConnectionOnCheckin" value="true" />
<property name="preferredTestQuery" value="SELECT 1" />
<property name="maxPoolSize" value="100" />
<property name="minPoolSize" value="5" />
</bean>
<bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase" depends-on="dataSourceLb">
<property name="dataSource" ref="dataSourceLb" />
<property name="changeLog" value="classpath:mastertest.xml" />
</bean>
and i added this dependency to pom.xml:
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.2.0</version>
</dependency>
mastertest.xml is valid, it runs with maven, but i want to make it run with Spring bean.
What is the problem with this configuration?
I changed changeLog property's value to "classpath:liquibase/mastertest.xml" because mastertest.xml is in the ProjectHome/src/main/resources/liquibase folder, and it is working now.

Eclipse Virgo Injected JPA EntityManager does not connect to Database

I am using Eclipse Virgo and I am trying to get annotation driven transaction management running but I keep running into the same issue.
Problem is that the EntityManager is injected and not null. But any query fails due to a connection error.
I used the setup according to GreenPages.
I have the following EntityManageFactory and TransactionManager configured
<bean id="emf"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitName" value="ShiftManagement" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="true" />
<property name="databasePlatform"
value="org.eclipse.persistence.platform.database.MySQLPlatform" />
</bean>
</property>
<property name="packagesToScan" value="....." />
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="emf" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
Also I have the following DataSources configured. Problem is, I tried them all, but when I try to connect to the database using a query, it doesn't work. Now, I am 100% sure that the credentials are OK, the DB is UP etc etc
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/shiftmanagement" />
<property name="username" value="root" />
<property name="password" value="rootroot" />
<property name="initialSize" value="5" />
<property name="maxActive" value="20" />
<property name="maxIdle" value="5" />
<!-- TRANSACTION_READ_COMMITTED = 2 -->
<property name="defaultTransactionIsolation" value="2" />
<!-- TRANSACTION_READ_UNCOMMITTED = 1 -->
<!-- <property name="defaultTransactionIsolation" value="1" /> -->
<property name="validationQuery" value="select 1 from dual" />
<property name="testOnBorrow" value="true" />
</bean>
Error when using commons-dbcp
Caused by: java.lang.UnsupportedOperationException: Not supported by BasicDataSource
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:901)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:132)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
Using Spring Datasource
<bean id="dataSource2"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/shiftmanagement" />
<property name="username" value="root" />
<property name="password" value="rootroot" />
</bean>
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/shiftmanagement
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
OK so then I tried the promising tomcat-jdbc library
<bean id="dataSource3" class="org.apache.tomcat.jdbc.pool.DataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/shiftmanagement" />
<property name="username" value="root" />
<property name="password" value="rootroot" />
<property name="initialSize" value="5" />
<property name="maxActive" value="10" />
<property name="maxIdle" value="5" />
<property name="minIdle" value="2" />
</bean>
And the following similar exception pops up
Caused by: org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: com.mysql.jdbc.Driver in KernelBundleClassLoader: [bundle=org.apache.tomcat.jdbc_1.1.0.1]
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:139)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:246)
I am using the following persistence.xml
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="ShiftManagement" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
....
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- Database options -->
<property name="eclipselink.target-database" value="MySQL"/>
<property name="eclipselink.weaving" value="false"/>
<property name="eclipselink.orm.throw.exceptions" value="true"/>
<!--
<property name="eclipselink.jdbc.read-connections.min" value="1"/>
<property name="eclipselink.jdbc.write-connections.min" value="1"/>
-->
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/shiftmanagement"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="rootroot"/>
<!-- Logging -->
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.logging.timestamp" value="false" />
<property name="eclipselink.logging.session" value="false" />
<property name="eclipselink.logging.thread" value="false" />
</properties>
</persistence-unit>
I inject the EntityManager using
#PersistenceContext
private EntityManager em;
I read some posts to remove the username and password from the persistence.xml but then the system complains there are that user = [null].
Any help is greatly appreciated.
Note: mysqld is running and I can connect using mysql -uroot -prootroot
OK so I used a fourth datasource and all my problems dissapeared :-)
<bean id="dataSource"
class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/shiftmanagement" />
<property name="username" value="${javax.persistence.jdbc.user}" />
<property name="password" value="${javax.persistence.jdbc.password}" />
</bean>
You have to use the org.springframework.jdbc.datasource.DriverManagerDataSource see this thread
And in this case you see that the mysql driver is not found
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/shiftmanagement