Netbeans Project: Data Source Troubleshooting

In NetBeans 7.1.1. I have a Java project for a web application that I am deploying to Tomcat 7. The project has been migrated from an earlier version from Netbeans (along with all my other projects).

The problem is that my project is now in an error state. Its name is red and has a yellow triangle in the blue globe project icon. When I right-click on a project, I see the option “Fix a data source problem”.

Unfortunately, this option does not solve the problem. When I select an option, I get a dialog with the text: “To solve, select the data source name below, then click“ Add Connection. ”Database connections for the data sources mentioned in this project cannot be found.”

When I select a data source that cannot be located (jdbc / mydb) and click the Add Connection button, it opens the New Connections Wizard, but when I click the Finish button, I get “Unable to add connection. Connection already exists".

The connection is already defined in my context.xml and my project works and deploys without 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 a Netbeans project from this "Solve a data source problem" problem?

+6
source share
7 answers

I realized that the solution was right under my nose.

Right-click the globe icon of your project> select a problem with the resolution of the data source> then select your jdbc name of your resource from the available options. > click add connection.

A window will appear, and you need to make sure that the resource URL matches the name of the database you are trying to connect to.

+3
source

I had the same problem, and to fix it, this is what I did:

  • In Netbeans, go to the Files view.

  • Locate the folder named setup inside your project.

  • Edit the datasource-1-jdbc.xml file (this name may differ).

  • Correct the data on it.

  • Go to the "Projects" section and right-click on your project.

  • Click "Fix a problem with the data source ...

  • Select a JDBC name and click Add Connection.

  • Configure the connection and it.

PD: I also deleted all the previous configured database connections (in the services> Databases category).

Hope this helps.

+3
source

I had the same problem. I tried all the tricks. Nothing succeeded. Therefore, without wasting time, I created a new project in Netbeans 7.1.2 and copied the directories from the old project to the new project.

Now it works great. Hope this helps

+2
source

The easiest way -

  • Delete persistent.xml file.

  • Go to any class of objects in the project and check the error next to the class name. He will ask you to create another persistent.xml.

  • 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 tools to import your data into a new table.

+1
source

I ran into the same problem. It can be solved by carefully editing in the add connection menu. Try matching the "host" and the URL between your actual definition in the context.xml file and in the add connection menu. My problem was using 127.0.0.1 as the host in context.xml when using localhost in the add connection menu.

+1
source

I had the same problem as soon as I changed the name of the project. What I did to solve the problem was a magical disease.

Phase 1

  • First, run the clean project.
  • Right-click the project name and select "Open Required Projects."
  • Ready to clean and build again

Is the problem resolved? No, then complete phase 2.

Phase 2

  • Open context.xml in configuration files
  • Delete connection pool
  • Repeat phase 1

I use Apache-Tomcat and MySQL. These processes solved the problem, and the system works without problems.

0
source

You can easily open a project from your new netbeans. Select the previous netbeans project project for the whole project, then the whole project will be in your new netbean.

-3
source

Source: https://habr.com/ru/post/912192/


All Articles