Eclipse reports error on my JPA project

前端 未结 10 1985
-上瘾入骨i
-上瘾入骨i 2021-02-04 07:39

Each time I make a JPA project Eclipse reports that there are errors in my project but I do not understand why it does so. I added image and errors below:

10条回答
  •  遇见更好的自我
    2021-02-04 08:10

    Read This if you want to solve your problem easily

    There is no problem in your Database. You just have to create a new connection from Eclipse to the same database which we do during Adding JPA capabilities to the Project.

    Steps:-
    Create a new database from your mysql prompt.
    Right click on your Project in Eclipse/MyEclipse, then go to Properties.
    Click on Eclipse/MyEclipse tab on the left and then click on JPA sub menu.
    Then Click on Create new Connection. Put a new Connection name. And add the same Database. (You can opt to change your database too, but same database will also do).
    Test Connection, and click on Finish.
    First Time it wont show that newly created Connection name. Just Click Ok to close that Window.

    Then, Right Click again on Project and then Click on Propeties. Now you can see your newly created Connection on that Connection drop down list. Selct that and Click OK.

    Your Error will vanish.

    Possible Reason for this error:-
    Eclipse creates connection with you database everytime you connect using any project using persistence.xml, but only for the first time.
    So, any changes after that, especially from the database side(table name etc.) will throw an error from Eclipse.

    Thank You.

提交回复
热议问题