ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 08 May 2017 My Price 9.00

Library Application JDBC

Please modify the attached code per the specifications below:

Week 6:

Library Application JDBC:

 

Task Description: Create a new service JDBC implementation for your Library application.  Modify your Factory so that it’s decoupled from the services it creates. 

You need add only one book to the database and it has an isbn and one author (optionally multiple authors).

You need to add IService marker interface.

Only a store method is required (and tested).

In BookSvcJDBCImpl connString name your library yournamelibrary. This means that student, Jane Doe, would name her library: doelibrary.

 

Below is supplemental information for this week:

  • Create and save a properties file.
  • Download and install MySQL and MySQL Workbench
  • Use of two command line interfaces: DOS/MAC command line and MySQL Command Line Client.
  • Create MySQL database and table and possibly view its schema.
  • Run the BookSvcJDBCImplTest/JUnit test.
  • Dump your data to an sql file.
  • Deliver your application and the sql file.

 

Properties file:

There are two ways to create your properties file. I suggest that you use the first one.

 

 “Modify Factory so that it is decoupled from the services it creates” means that it will retrieve and return the implementation class name from the loaded Properties file name-value pair. In your Windows’ directory/folder for this week's NetBeans'  Java project, create a subdirectory called config under the project directory/folder. Create a Windows’ file called properties.txt with name-value pairs and store this file in the config directory. The name-value pair for wk6 could be: IBookSvc = library.services.BookSvcJDBCImpl. (See Wk6 Lesson: Refactoring the Factory).

Alternatively, the properties/configurations file can be directly inserted into the services package via NetBeans: services (right click) -> New -> Other -> Other -> Properties File. However the file extension will be “properties”, not “txt”, i.e. service.properties or properties.properties. See NetBeans Help “Creating and Deleting a Resource Bundle”.

 

Explanation of code from wk 6 Lesson: Refactoring the FactoryComments are extracted from the API for the classes FileInputStream and Properties.

 

               private String getImplName(String serviceName) throws Exception {

                               FileInputStream fis = new

                                  FileInputStream("config/properties.txt");

                                  // Constructs a FileImageInputStream that will read from a given File.

 

                               Properties props = new Properties();

                               // Creates an empty property list with no default values

 

                               props.load(fis);

                               //  Reads a property list (key and element pairs) from the input byte stream.

                               fis.close();

 

                               return props.getProperty(serviceName);

//   Searches for the property with the specified key in this property list.

 //  Returns String or null.

                 }

 

Download and install MySQL, MySQL Workbench

 

            Week 6 PPP slides 11- 14 and 34 - 40. are dated. Take a look at: http://www.mysqltutorial.org/install-mysql/ before download/install.

 

            See:  http://dev.mysql.com/downloads/mysql/

Choose “MySQL Community Server”

 Note: you may have to register as a user

Use MSI installer (x86, 32-bit), MySQL Installer MSI. It will offer 64 bit during install.

It will install MySQL to include server and Command Line Client/Monitor, Connector/J, MySQL Workbench

 

                                MySQL Command-Line Tool/Monitor

http://dev.mysql.com/doc/refman/5.7/en/mysql.html

 

Configuring Connector/J

See wk6 PPT slide 41-422.

           

MySQL Workbench

 download/install: https://dev.mysql.com/downloads/workbench/

 

            MySQL tutorials:

             http://dev.mysql.com/doc/refman/5.x/en/tutorial.html

                http://www.mysqltutorial.org/  

Connecting to a MySQL Database:

https://netbeans.org/kb/docs/ide/mysql.html

 

Command line commands

DOS command line prompt and commands:

Prompt:  C:>

About the only DOS commands you need to understand for MySQL are cd and cd. See Microsoft DOS and command prompt for an explanation. http://www.computerhope.com/msdos.htm

 

The mysqldump command may result in an “access is denied” error if you are not logged in as the Administrator. See this reference to  Elevated  Command Prompt. Note that it also applies to Win8:  http://www.computerhope.com/jargon/e/elevated.htm

 

For MAC command line commands, do an Internet search using: “MAC Terminal”

 

MySQL 5.6 Command Line Client

One way to get the Command Line Client and its mysql> prompt:

  • cd where you have the MySQL Server stored
  • cd to the bin folder
  • Enter mysql -uroot -p and get a prompt to enter password. Enter "admin".
  • Should see this sort of message ending with prompt mysql>

 

Welcome to the MySQL monitor.  Commands end with ; or g.

Your MySQL connection id is 6

Server version: 5.6.30 MySQL Community Server (GPL)

 

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

 

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

 

mysql>

 

Alternative is search for it in the tiles of windows 8 and get Enter password: admin and get same output.

 

Create MySQL database and table and possibly view its schema.

MySQL 5.x Command Line (See wk6 PPT slides 18 – 22&

http://dev.mysql.com/doc/refman/5.x/en/mysql.html

mysql> create database yournamelibrary;

mysql> use yournamelibrary;

mysql> create table book (author VARCHAR(20), isbn VARCHAR(10));

mysql> show tables;

mysql> describe  book;

 

MySQL database stores our libraries at

C:ProgramDataMySQLMySQL Server 5.xdata

 

Run JUnit Test

JDBC BookSvcJDBCImplTest uses the Refactored Factory.

Inserts your data into the database. You can check your database:

mysql> select * from book;

 

Dump your data to an sql file.

DOS:

For using mysqldump see Dumping Data in SQL Format with mysqldump.

http://dev.mysql.com/doc/refman/5.x/en/mysqldump-sql-format.html

 

Either put your MySql bin folder in classpath environmental variable.

C:Program FilesMySqlMySql Server 5.xbin

 

Or start with moving to your MySQL bin folder using DOS:

C: > cd C:Program FilesMySQLMySQL Server 5.xbin

 

Then dump yournamelibrary with:

If changed classpath:

C: > mysqldump -uroot –padmin  yournamelibrary > yourname.sql

http://blog.tatedavies.com/2011/01/18/how-to-use-mysqldump/

Note: If you use Microsoft Windows power shell  instead of  command prompt, unwanted characters may be inserted into the dump file causing an error when the login "admin" in entered.

 

It seems that MySQL 5.6 needs this approach:

C: > mysqldump.exe -u root -p yournamelibrary > yourname.sql

then type in 'admin' password

 

Or from prompt:

C:Program FilesMySQLMySQL Server 5.xbin>

 

Note: “yournamelibrary” means that student, Jane Doe, would name her library doelibrary and “yourname.sql”  means her sql file would be named doe.sql.

 

Deliver your application and the sql file.

Re: Zip up your NetBeans project, and send it to your facilitator.  Include your sq file.

           

Remember to add your Connector/J file to the Libraries folder in your NetBeans project for this week. Otherwise I get a "Broken reference" message.

 

Note: I test if the isbn and author in your sql file book table matches your BookSvcJDBCImplTest() book arguments. Please either clear any test data you may have put in the database, run NetBeans Test File on BookSvcJDBCImplTest, then perform mysqldump (or advise me as to what I will see in your book table in addition to what is in your test file).

Attachments:

Answers

(11)
Status NEW Posted 08 May 2017 04:05 AM My Price 9.00

-----------

Not Rated(0)