[英]“unknow database” even though i have created database correctly
I'm working on java web application. 我正在研究Java Web应用程序。 i'm using jboss wildfly 10.x server, and hibernate for persistence.
我正在使用jboss wildfly 10.x服务器,并保持休眠状态。 Problem is when i start server it says there is a
unknow database "DATABASE"
which i did not create and not give a name about DATABASE
anywhere but if i create DATABASE
it works and fill my correct database. 问题是,当我启动服务器时,它说有一个
unknow database "DATABASE"
,我没有创建该unknow database "DATABASE"
,也没有在任何地方给出有关DATABASE
的名称,但是如果我创建DATABASE
它将起作用并填充正确的数据库。
here is my *-ds.xml: 这是我的* -ds.xml:
<datasources>
<datasource jndi-name="java:jboss/datasources/atlantisDS"
pool-name="atlantisPool">
<connection-url>jdbc:mysql://localhost/atlantis?characterEncoding=UTF8
</connection-url>
<driver>mysql</driver>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>5</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>were</user-name>
<password>142536</password>
</security>
</datasource>
</datasources>
here is persistence.xml: 这是persistence.xml:
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="atlantisPU" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:jboss/datasources/atlantisDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
I have looked for DATABASE
every *.xml
files but i could not get a clue. 我已经在每个
*.xml
文件中查找了DATABASE
但找不到线索。 so what is problem and how can i fix it? 那么问题是什么,我该如何解决?
Because you have added this line 因为您已经添加了这一行
<jta-data-source>java:jboss/datasources/atlantisDS</jta-data-source>
it tells container that look for datasource in jboss config file or *-ds.xml 它告诉容器在jboss配置文件或* -ds.xml中寻找数据源
so open your jboss's standalone file and look for code something like this or in your *-ds.xml 因此,请打开jboss的独立文件,然后在* -ds.xml中查找类似这样的代码
<datasource jndi-name="java:jboss/datasources/sampleDS" pool-name="sampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://192.168.155.110:3306/databasename</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
</datasource>
you have defined database name as atlantis 您已将数据库名称定义为亚特兰蒂斯
Database must exist in Mysql whether or not to create tables automatically is optional 无论是否自动创建表,数据库都必须存在于Mysql中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.