How to use a database as your database source in JPA

前端 未结 2 752
忘了有多久
忘了有多久 2021-01-26 05:56

I\'m new in developing apps in JBoss so I followed their tutorials specially in making the Ticket Monster. For now, I\'ve created an Event JPA Entity and in the run, it shows th

2条回答
  •  粉色の甜心
    2021-01-26 06:34

    So after I posted on the jboss forum, here's the link Wildfly 10: Cannot upload deployment , Wolfgang Mayer answered that I should not declared a datasource more than once. Here's the step.

    1.You can set a datasource via your Admin Console(localhost:9990) or via your Project(*-ds.xml), not both. Please remember the JNDI(Java Naming and Directory Interface) of your Datasource.

    Example: Datasource Name:PostgresDS JNDI:java:/PostgresDS Connection URL: jdbc:postgresql://host:port/databasename

    2.Tell your project or war to use your datasource you've created. Edit your pesistence.xml and put the JNDI of your datasource.

    Example:

    
    
       
          java:/PostgresDS
          
             
             
             
          
       
    
    

    3.(Optional) If you created your datasource in Admin Console, delete your *-ds.xml file in your project folder to prevent the "Datasource is already registered" error.

提交回复
热议问题