简体   繁体   English

即使我已经正确创建了数据库,“未知数据库”

[英]“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.

相关问题 即使我有一个 liquibase.properties 文件,也未指定数据库 Url - Database Url not specified even though I have a liquibase.properties file “数据库被锁定”即使我调用了database.close() - “Database is locked” Even though I did call database.close() 即使存在以下情况,createNamedQuery也不返回数据库中的对象 - createNamedQuery not return objects in the database even though there are 即使我调用em.remove(),JPA也不会删除数据库中的对象 - JPA is not deleting an object in my database even though I called em.remove() 即使java端有数据,也无法使用httpurlconnection将数据发布到数据库 - unable to post data to database with httpurlconnection even though there is data in the java side 为什么即使与数据库的连接正常,查询也不起作用? - Why queries won't work even though connection with database is ok? Firebase实时数据库长值始终返回0,即使它不是 - Firebase Realtime Database long values always return 0 even though it is not 找不到Java数据库驱动程序,即使它位于jar文件中 - Java database driver not found, even though it's in the jar file Spring 引导应用程序应该启动,即使 Cassandra 数据库已关闭 - Spring Boot application should start even though Cassandra database is down 即使我有 JScrollPane,JTable 列标题也没有显示 - JTable column titles not showing up even though I have a JScrollPane
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM