Netbeans Project: Resolve Data Source Problems

18,268

Solution 1

I figured it out on that the solution had been right under my nose all along.

Right click the globe icon of your project > select resolve datasource problem > then select your jdbc name of your resource from the options available. > click add a connection.

A window appears and you should make sure that the resource reference URL is the same as the name of the database you are trying to connect to.

Solution 2

I had the exact same issue and in order to fix it, this is what I did:

  1. In Netbeans, go to the Files view.

  2. Locate inside your project a folder called setup.

  3. Edit the file datasource-1-jdbc.xml (this name may vary).

  4. Correct de data on it.

  5. Go to Projects view and right click on your project.

  6. Click on Resolve data source problem...

  7. Select the JDBC name and click on Add connection.

  8. Configure the connection and that's it.

PD: I've also removed all previous configured connection to the database (in the services > Databases category).

Hope this helps.

Solution 3

I had the same problem. Tried all the tricks. Nothing worked. So without wasting any more time I created a new project in Netbeans 7.1.2 and copied the directories from the old project in to the new project.

It works fine now. Hope this helps

Solution 4

The easiest way is

  1. Delete the persistent.xml file.

  2. Go to any of your entity class on the project and check the error close to the class name. It will request you to create another persistent.xml.

  3. Follow the link and create a new persistent.xml with the required data-source name.

This process will create a new table structure for your project without any data.

You can use other means to import your data to the new table.

Solution 5

I have encountered the same problem. It can be resolved by carefully editing at the add connection menu. Try match the 'host' , and url between your actual definition at the context.xml and the add connection menu entry. My problem was using 127.0.0.1 as host in the context.xml while using localhost in the add connection menu.

Share:
18,268
Kdeveloper
Author by

Kdeveloper

Web developer

Updated on June 16, 2022

Comments

  • Kdeveloper
    Kdeveloper almost 2 years

    In Netbeans 7.1.1. I have a Java project for a web application that I deploy on Tomcat 7. The project is migrated from an earlier version from Netbeans (together with all my other projects).

    The problem is that my project now is in an error state. Its name is in red and it has a little yellow triangle in its blue globe project icon. When I right click on the project I see the option to "Resolve Data Source Problem.".

    Unfortunately this option does not resolve the problem. When I choose the option I get a dialog with the text: "To resolve, select a Data Source name below then click Add Connection. Database connections for the Data Sources referenced in this project could not be located."

    When I select the data source that can't be located (jdbc/mydb) and press the "Add Connection" button, it opens the "New Connection Wizard" but when I press the "Finish" button, I get an "Unable to add connection. Connection already exists."

    The connection is already defined in my context.xml and my project is running and deploying without any problems.

    Here is my context.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/myapp.com">
        <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" 
            maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/mydb" 
            password="secret" type="javax.sql.DataSource" 
            url="jdbc:mysql://127.0.0.1:3306/mydb?autoReconnect=true" 
            username="user" validationQuery="select 1"/>
    
    </Context>
    

    How can I get my Netbeans project out of this "Resolve Data Source problem"?