Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Connecting a DB to Netbeans first time

  1. #1
    Junior Member
    Join Date
    Nov 2018
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Connecting a DB to Netbeans first time

    To learn about databases, I am working through this Murach book published in 2014. I am using NetBeans 8.2, Tomcat 8.0, and I have two MySQL Servers installed, version 5.5 and version 8.0. I also have MySQL Workbench 8.0 CE installed and a Tomcat 9.0. I have gotten pre-built web applications to work with a Tomcat server. The exercise I am working on is the final test run to make sure that all the software I need is correctly installed and configured. At this point all I really know is Java. I don't know anything about databases yet. I've only blindly followed installation instructions. This is the last thing I need to get working before I start learning stuff.

    From the book:
    Exercise 3-3: Run web applications that use a database
    This exercise has you run two of the web applications presented in this book that use a database. This forces you to register the connections for the two databases that are used by this book. For this to work, you must install and configure the MySQL database server as described in appendix A (PC) or B (Mac).

    Use the Murach database
    1. Open the ch12email project that's in the book_apps directory.

    2. If that displays a dialog box that says the database connection needs to be registered with NetBeans, click on the Close button for this dialog box. Then right-click on the project, select the Resolve Data Sources Problem item, and use the resulting dialog boxes to resolve the data source problem and register the database connection for the murach database.

    3. Run the application to see how it works. After you enter your name and email address and click on the Join Now button, your entries are saved to a MySQL database.

    4. ...

    5. ...
    I was able to open the project.
    project01.jpg

    I did not get a database connection dialog box warning, but if I right click on the project, I can select Resolve Data Sources. A dialog box opens which allows me to "Add Connection".
    resolveDataSources.JPG

    Doing so opens the New Connection Wizard.
    new connection wizard 01.JPG

    While looking around for help on Stack Overflow, I ran into this suggestion:
    check the context.xml file in Web Pages -> META-INF, the username="user" must be the same as the database user, in my case was root, that solved the connection error
    which prompted me to check these connection wizard login boxes against the context.xml.

    My context.xml:
    <Resource name="jdbc/murach" auth="Container" 
            driverClassName="com.mysql.jdbc.Driver" 
            url="jdbc:mysql://localhost:3306/murach" 
            username="murach_user" password="sesame" 
            maxActive="100" maxIdle="30" maxWait="10000" 
            logAbandoned="true" removeAbandoned="true" 
            removeAbandonedTimeout="60" type="javax.sql.DataSource" />

    This information seems to match, but when I click on "Test Connection", I get this error:
    Cannot establish a connection to jdbc:mysql://localhost:3306/murach using com.mysql.jdbc.Driver (Unable to load authentication plugin 'caching_sha2_password'.)
    Last edited by jackjordan; November 28th, 2018 at 09:15 PM.

  2. #2
    Junior Member
    Join Date
    Nov 2018
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Connecting a DB to Netbeans first time

    I found an answer and posted it on Stack Overflow.

Similar Threads

  1. Converting Military Time to Standard Time
    By GMPoison in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 30th, 2014, 01:28 AM
  2. Problem in getting time of different time zone
    By anks.coder in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 13th, 2013, 06:44 PM
  3. Using Date() to get Start Time and Finish Time of a copyFiles method
    By dalythe in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: June 17th, 2013, 10:50 PM
  4. Connecting netbeans with sql database
    By babe20042004 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 15th, 2013, 04:57 PM
  5. Hello, first time caller long time programmer....
    By P2C2N in forum Member Introductions
    Replies: 3
    Last Post: December 10th, 2012, 11:53 AM

Tags for this Thread