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 4 of 4

Thread: In need of some serious help

  1. #1
    Member
    Join Date
    Mar 2021
    Location
    Ontario, Canada
    Posts
    35
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default In need of some serious help

    Hello Everyone,
    I am coming close to finishing my last course on Java. The chapter I am on is 'Accessing Databases with JDBC'.
    I am using the textbook Java, How to program' edition 11 by Paul and Harvey Deitel.
    On page 1067, Creating the chapter's database on Windows, states the following;
    1. Run notepad as Administrator
    2. From notepad open the batch file 'setEmbeddedCP.bat that is located in the JDK installation folder's
    db\bin folder

    There are a lot more steps to follow but I cannot get past step 2 at this time

    My problem is that in my JDK folder all I have are the following folder's;
    a. bin
    b. conf
    c. include
    d. jmods
    e. legal
    f. libs

    As you can see, I do not have the required folder (and YES I did check the bin folder shown, but the require bat file was not there). Can anyone point me to a location where one can possible download this folder with all its contents.
    I looked all over the Java website, with no luck and without it, my course stops here.

    Please help

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: In need of some serious help

    What versions of software are you using?
    I found the db folder here:
     Volume in drive D is Work
     Volume Serial Number is 1A36-57D4
     
     Directory of D:\Java\jdk1.7.0_45\db\bin
     
    11/28/2021  03:46 PM    <DIR>          .
    11/28/2021  03:46 PM    <DIR>          ..
    12/21/2013  10:27 AM             5,740 dblook
    12/21/2013  10:27 AM             1,387 dblook.bat
    12/21/2013  10:27 AM             2,426 derby_common.bat
    11/28/2021  03:46 PM                 0 DirList.txt
    12/21/2013  10:27 AM             5,876 ij
    12/21/2013  10:27 AM             1,379 ij.bat
    12/21/2013  10:27 AM             5,801 NetworkServerControl
    12/21/2013  10:27 AM             1,413 NetworkServerControl.bat
    12/21/2013  10:27 AM             1,073 setEmbeddedCP
    12/21/2013  10:27 AM             1,278 setEmbeddedCP.bat
    12/21/2013  10:27 AM             1,079 setNetworkClientCP
    12/21/2013  10:27 AM             1,284 setNetworkClientCP.bat
    12/21/2013  10:27 AM             1,075 setNetworkServerCP
    12/21/2013  10:27 AM             1,273 setNetworkServerCP.bat
    12/21/2013  10:27 AM             5,807 startNetworkServer
    12/21/2013  10:27 AM             1,397 startNetworkServer.bat
    12/21/2013  10:27 AM             5,810 stopNetworkServer
    12/21/2013  10:27 AM             1,403 stopNetworkServer.bat
    12/21/2013  10:27 AM             5,789 sysinfo
    12/21/2013  10:27 AM             1,389 sysinfo.bat
                  20 File(s)         52,679 bytes
                   2 Dir(s)  58,368,090,112 bytes free


    What is the purpose of the edit you need to make? Can your version of the JDK do what is needed for the project?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Mar 2021
    Location
    Ontario, Canada
    Posts
    35
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: In need of some serious help

    My version is JDK-15.0.1

     

    Directory of C:\Program Files\Java

    2020-11-17 07:27 PM <DIR> .
    2020-11-17 07:27 PM <DIR> ..
    2020-11-17 07:27 PM <DIR> jdk-15.0.1
    0 File(s) 0 bytes
    3 Dir(s) 620,601,839,616 bytes free

    C:\Program Files\Java>cd\Program Files\Java\jdk-15.0.1

    C:\Program Files\Java\jdk-15.0.1>dir
    Volume in drive C is Acer
    Volume Serial Number is F8C5-C787

    Directory of C:\Program Files\Java\jdk-15.0.1

    2020-11-17 07:27 PM <DIR> .
    2020-11-17 07:27 PM <DIR> ..
    2020-11-17 07:27 PM <DIR> bin
    2020-11-17 07:27 PM <DIR> conf
    2020-09-15 02:08 PM 3,244 COPYRIGHT
    2020-11-17 07:27 PM <DIR> include
    2020-11-17 07:27 PM <DIR> jmods
    2020-11-17 07:27 PM <DIR> legal
    2020-11-17 07:27 PM <DIR> lib
    2020-11-17 07:27 PM 1,231 release
    2 File(s) 4,475 bytes
    8 Dir(s) 620,593,610,752 bytes free

    C:\Program Files\Java\jdk-15.0.1>




    According to the book I am to do the following;

    3. Locate the line

    @rem set DERBY_INSTALL =

    and change it to

    @set DERBY_INSTALL=%JAVA_HOME%\db

    What the purpose is, I do not know. I am just learning and trying to follow along step by step.

    I tried to run the sample code that was provided,
    package books;
    // Fig. 24.23: DisplayAuthors.java
    // Displaying the contents of the Authors table.
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
     
    public class DisplayAuthors {
       public static void main(String args[]) {
          //final String DATABASE_URL = "jdbc:derby:books";
          final String DATABASE_URL = "books";
          final String SELECT_QUERY =                            
             "SELECT authorID, firstName, lastName FROM authors";
     
          // use try-with-resources to connect to and query the database
          try (                                                        
             Connection connection = DriverManager.getConnection(      
                DATABASE_URL, "deitel", "deitel");                     
             Statement statement = connection.createStatement();       
             ResultSet resultSet = statement.executeQuery(SELECT_QUERY)) {
     
             // get ResultSet's meta data
             ResultSetMetaData metaData = resultSet.getMetaData();
             int numberOfColumns = metaData.getColumnCount();     
     
             System.out.printf("Authors Table of Books Database:%n%n");
     
             // display the names of the columns in the ResultSet
             for (int i = 1; i <= numberOfColumns; i++) {
                System.out.printf("%-8s\t", metaData.getColumnName(i));
             }
             System.out.println();
     
             // display query results
             while (resultSet.next()) {
                for (int i = 1; i <= numberOfColumns; i++) {
                   System.out.printf("%-8s\t", resultSet.getObject(i));
                }
                System.out.println();
             } 
          }
          catch (SQLException sqlException) {
             sqlException.printStackTrace();
          }                                                   
       } 
    } 
     
     
     
     
    /**************************************************************************
     * (C) Copyright 1992-2018 by Deitel & Associates, Inc. and               *
     * Pearson Education, Inc. All Rights Reserved.                           *
     *                                                                        *
     * DISCLAIMER: The authors and publisher of this book have used their     *
     * best efforts in preparing the book. These efforts include the          *
     * development, research, and testing of the theories and programs        *
     * to determine their effectiveness. The authors and publisher make       *
     * no warranty of any kind, expressed or implied, with regard to these    *
     * programs or to the documentation contained in these books. The authors *
     * and publisher shall not be liable in any event for incidental or       *
     * consequential damages in connection with, or arising out of, the       *
     * furnishing, performance, or use of these programs.                     *
     *************************************************************************/

    but I get the following error
     

    run:
    java.sql.SQLException: No suitable driver found for books
    at java.sql/java.sql.DriverManager.getConnection(DriverManager .java:702)
    at java.sql/java.sql.DriverManager.getConnection(DriverManager .java:228)
    at books.DisplayAuthors.main(DisplayAuthors.java:20)
    BUILD SUCCESSFUL (total time: 7 seconds)




    Also, just in case you need to know, I am running this on NetBeans IDE 12.4

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: In need of some serious help

    I do not use databases and have no knowledge about solving your problems.
    Try asking about using the Derby database on this forum: http://www.coderanch.com/forums

    Also post a query on Google: Derby database
    If you don't understand my answer, don't ignore it, ask a question.