Due Monday, Sept. 19, in class, on paper. Be sure to get a UNIX/Linux
account for cs636 by Friday, 9/9, to list your username for the needed
Oracle and mysql accounts, and access to topcat.cs.umb.edu.
1. Basic HTML and URLs, intro to web apps.
--Learn about absolute and relative URLs, say by looking at this
tutorial on URLs and looking at the examples in Murach, pg. 101.
--Read Murach, Chap. 1, through pg. 17 for an intro to web apps.
--Read Murach, Chap. 4 through pg. 105. We will go on to CSS and HTML forms in the next homework.
2. Review SQL. Read Murach pp. 364-373. Go to sqlzoo.net, Pull down the Tutorials menu, and select the following tutorials:
3. Review Java OO principles,
specifically the idea that all Java classes are subclasses of the
Object class, and thus must have all the methods of the Object
class. You can see the Object class API (and any other standard class)
by following the link on the class web page under Resources Java (4th
line down under Resources). Choose “Object” in the pane
titled All Classes, and the API will be displayed on the right.
a. What are the three most important Object methods? (Hint: their names start with e, h, and t). Because all objects have these methods, we can use HashSet to contain any set of objects (we'll stick to sets of same-type objects in our work).
b. Show equals in use by writing one if (…) that checks whether s String s is equal to a String t, character by character. Explain what this comparison is doing if s = “abc” and t = “abx”. Compare this to what happens in if (s == t).
c. Find the hashCode and toString values for String s = “abc”. Also for the Integer of value 6.
d. Write a small Java class Box1.java that has private int fields x, y for the dimensions of the (2-dimensional) box in mm. Give it getters and setters for x and y, and a simple constructor that takes x and y values, but no other methods. This is a simple “Java Bean”. For Box1 objects b and c, separately created but both describing 10x12 boxes, what is b.equals(c)? What is being compared here?
e. For Java class Box2.java, start from the Box1.java code and add an equals method that compares the x’s and y’s of the two Box2 objects to see if they are both the same or not. Make sure your equals method overrides Object.equals by using the annotation @Override (it’s easy to go wrong here). For an example, see http://www.geeksforgeeks.org/overriding-equals-method-in-java/.Write a hashCode method that is consistent with your equals method. Consistent here means satisfying the second bulleted requirement under the Object.hashCode documentation, namely “If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.” Finally, write a toString method that returns “10x12” for a 10 by 12 box. For Box2 objects b and c, separately created but both describing 10x12 boxes, what is b.equals(c)?
4. Review Java Collection classes. Look at the Collection Framework home page at Oracle, and from there the Collections Framework Overview and Collections Tutorial, for Java 8. .
a. What are the two most important concrete classes that are available for the Set interface? the Map interface?
b. Explain how you can find all the elements of a given Set object. Does your answer also apply to Lists? other things? what class of objects?
c. Explain how you can find all the keys of a given Map.
d. Write a Java fragment that creates a Map from String to Integer. Add the association "x" -> 1, that is, key "x" maps to Integer 1.
a. What Java classes (include package name) support JDBC and are used
in the Oracle tutorial section “Setting Up Tables”?
For each, briefly explain what it provides. Note that con is
assumed to be an available field of type Connection.
b. Do you need a new Connection for each SQL statement? Explain.
c. Find the JDBC API documentation among the usual JSE Javadocs at http://docs.oracle.com/javase/8/docs/api/. In particular, read Connection.close() and explain what it means. The "resources" here involve the TCP/IP connection to the database, an OS resource not directly managed the the Java vitual machine (JVM.)
d. Explain how to use the "getXXX" methods. What getXXX methods would you normally use with a VARCHAR(100) column? a FLOAT column? a DECIMAL(7,2) column? a TIMESTAMP column? Explain what these SQL datatypes mean. For detailed info on JDBC and SQL datatypes, see http://docs.oracle.com/javase/6/docs/technotes/guides/jdbc/getstart/mapping.html#996857.
User ronghui, for example, will have an account on mysql on topcat with username ronghui, password ronghui, and a database named ronghuidb. To access it, login to topcat.cs.umb.edu and use the command:
mysql –u ronghui –D ronghuidb –p
and enter ronghui at the password prompt. Another way is shown on pg. 351 of Murach:
mysql –u ronghui –p
Similarly run JdbcCheckup on your mysql account. You can log in
on topcat and use the mysql command to look at the database. Also try
out hsqldb (see header comment on JdbcCheckup.java for directions).
Record your success or problems.
c. Try out the Data Source Explorer view in eclipse. Click on the "New Connection Profile" icon (it has a little plus on it) in the Data Source Explorer view, and add a new Connection to localhost (and have the tunnel working), with driver MySQL (with driver jar from the jdbc directory), Database xxxxdb, URL jdbc:mysql://localhost/xxxxdb, and User name xxxx, where xxxx is your username. See your welcome table there. Record your success or problems.
d. Similarly set up an eclipse Connection to Oracle and view your welcome table there, and similarly for hsqldb (you need to run the hsqldb server separately as detailed in the header comment to JdbcCheckup.java.)
7. Report on your DevelopmentSetup progress and/or problems. Show your final "env" and "set" output, or the relevant subset of it. You may use Netbeans rather than eclipse if you want, but class demos and directions will be using eclipse. Also, Netbeans does not support multi-directory source comparison, which we will occasionally use.