简体   繁体   中英

Java Netbeans: Editing the MySQL DB connection infos

I just created a new project with NetBeans using the database template to connect to a MySQL database. After searching a while I got a question and hope anyone can help me with that: I want to create a dialog in my application to change the connection-informations to the MySQL Server. I realized that the template gets the infos out of the persistence.xml file when it compiles. But I cant find the point in the source code where he reads the xml file and gets the informations. Is there any way to hardcode the IP adress and the Database name and so on in the code?

Thanks for your help!

Don't use the Swing Application Framework.
Newer NetBeans IDEs will display this disclaimer if you create a JavaDesktopApplication project:

Note that JSR-296 (Swing Application Framework) is no longer developed and will not become part of the official Java Development Kit as was originally planned. You can still use the Swing Application Framework library as it is, but no further development is expected. If you are looking for a Swing-based application framework, consider using the NetBeans Platform [platform.netbeans.org][1], which is a full-featured platform suitable for creating complex and scalable desktop applications. The Platform contains APIs that simplify the handling of windows, actions, files, and many other typical application elements.

As to your question regarding the persistance.xml file, that's read somewhere in the framework (probably in org.jdesktop.application.Application). It's not in any of the files in your project. All you can really do is change the values in the file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM