मैं जेपीए और सी 3 पी 0 का उपयोग कर रहा हूं और एक टेबल से पूछताछ करने और एक स्टैक ट्रेस वापस लेने का प्रयास कर रहा हूं कि दावा नहीं है कि तालिका मौजूद नहीं है। मैं डीबी में कनेक्शन खोल सकता हूं, उदाहरण के लिए, डीबी विज़ुअलाइज़र, और वहां टेबल देखें। असल में, मेरे ऐप से डीबग स्टेटमेंट्स से पता चलता है कि यह कनेक्शन बनाने और इसकी व्यवहार्यता का परीक्षण करने में सक्षम है। लेकिन फिर यह टेबल नहीं ढूंढ रहा है।MySQLSyntaxErrorException: तालिका XYZ मौजूद नहीं है
15:45:53.940 [http-8080-1] DEBUG o.h.e.j.i.LogicalConnectionImpl - Obtaining JDBC connection
15:45:53.940 [http-8080-1] DEBUG c.m.v.c.i.C3P0PooledConnectionPool - Testing PooledConnection [[email protected]] on CHECKOUT.
15:45:53.949 [http-8080-1] DEBUG c.m.v.c.i.C3P0PooledConnectionPool - Test of PooledConnection [[email protected]] on CHECKOUT has SUCCEEDED.
15:45:53.950 [http-8080-1] DEBUG c.m.v.resourcepool.BasicResourcePool - trace [email protected] [managed: 3, unused: 2, excluded: 0] (e.g. [email protected])
15:45:53.950 [http-8080-1] DEBUG o.h.e.j.i.LogicalConnectionImpl - Obtained JDBC connection
15:45:53.966 [http-8080-1] DEBUG org.hibernate.SQL - select alert0_.rrdb_key as rrdb1_0_, alert0_.date as date0_, alert0_.hostname as hostname0_, alert0_.message as message0_, alert0_.program as program0_ from reportsDb.alerts alert0_ where (alert0_.message not like '%Anomolous%') and (alert0_.message not like '%Requeue%')
Hibernate: select alert0_.rrdb_key as rrdb1_0_, alert0_.date as date0_, alert0_.hostname as hostname0_, alert0_.message as message0_, alert0_.program as program0_ from reportsDb.alerts alert0_ where (alert0_.message not like '%Anomolous%') and (alert0_.message not like '%Requeue%')
15:45:54.013 [http-8080-1] DEBUG c.m.v2.c3p0.impl.NewPooledConnection - [email protected] handling a throwable.
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'reportsDb.alerts' doesn't exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.6.0_45]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) ~[na:1.6.0_45]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) ~[na:1.6.0_45]
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) ~[na:1.6.0_45]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) ~[mysql-connector-java-5.1.6.jar:na]
...
यहाँ persistence.xml है (/ src में/मुख्य/संसाधन/META-INF):
<?xml version="1.0" encoding="UTF-8"?>
<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="reportsDb" transaction-type="RESOURCE_LOCAL">
<description>Hibernate</description>
<class>com.pronto.mexp.common.entity.Alert</class>
</persistence-unit>
</persistence>
applicationContext.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
<bean id="reportsDbEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="reportsDbDataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true"/>
<property name="generateDdl" value="false" />
<property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
</bean>
</property>
<property name="persistenceUnitName" value="reportsDb" />
<property name="jpaDialect" ref="jpaDialect"/>
</bean>
<bean id="reportsDbDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<!--<property name="jdbcUrl" value="jdbc:mysql://devdbrw01:3306/mexp"/>-->
<property name="jdbcUrl" value="jdbc:mysql://report101:3306/worker_events"/>
<property name="user" value="********"/>
<property name="password" value="********"/>
<property name="acquireRetryDelay" value="1000"/>
<property name="acquireRetryAttempts" value="4"/>
<property name="breakAfterAcquireFailure" value="false"/>
<property name="testConnectionOnCheckout" value="true"/>
<property name="maxConnectionAge" value="14400"/>
<property name="maxIdleTimeExcessConnections" value="1800"/>
</bean>
<!-- DAOs -->
<bean id="genericReportsDbDAO" class="com.pronto.mexp.common.dal.GenericReportsDbJPADAOImpl"/>
<bean id="alertJPADAO" class="com.pronto.mexp.dal.AlertJPADAOImpl" parent="genericReportsDbDAO"/>
</beans>
बात मैं संदिग्ध लगता है हाइबरनेट क्वेरी का हिस्सा है जहां यह select ... from reportsDb.alerts alert0_
से पूछताछ करने का प्रयास करता है - मैं कैसे पुष्टि करूं कि "reportsDb" वास्तव में मेरे डेटा स्रोत के लिए खड़ा है जिसे मैंने applicationContext.xml में spec'd किया था?
ईटीए: इकाई, चेतावनी, इस तरह दिखता है:
@Entity
@Table(name = "alerts", catalog = "reportsDb")
public class Alert {
int rrdbKey;
String hostname = "";
String message = "";
String program = "";
Date date = new Date();
@javax.persistence.Column(name = "rrdb_key", nullable = false, insertable = false, updatable = false, length = 10, precision = 0)
@Id
public int getRrdbKey() {
return rrdbKey;
}
public void setRrdbKey(int rrdbKey) {
this.rrdbKey = rrdbKey;
}
@javax.persistence.Column(name = "hostname", nullable = false, insertable = false, updatable = false, length = 32, precision = 0)
@Basic
public String getHostname() {
return hostname;
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
@javax.persistence.Column(name = "message", nullable = false, insertable = false, updatable = false, length = 128, precision = 0)
@Basic
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@javax.persistence.Column(name = "program", nullable = true, insertable = false, updatable = false, length = 40, precision = 0)
@Basic
public String getProgram() {
return program;
}
public void setProgram(String program) {
this.program = program;
}
@javax.persistence.Column(name = "date", nullable = false, insertable = false, updatable = false, length = 19, precision = 0)
@Basic
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}
कैसे इकाई कैसा दिखता है के साथ "बनाने ड्रॉप" की जगह? @Table एनोटेशन में आप तालिका, कैटलॉग और स्कीमा नाम – German
@German - अच्छी बात बता सकते हैं, मैं भूल गया - जोड़ने के लिए संपादित किया गया। – barclay