Need help answering the following 3 questions in java, thanks :D 1. Describe how
ID: 3824716 • Letter: N
Question
Need help answering the following 3 questions in java, thanks :D
1. Describe how the Model-View-Controller paradigm relates to JavaFX GUIs, Be sure to describe how each aspect of the paradigm relates to different aspects or components of JavaFX. If it aids your answer, feel free to describe a real or fictional application (e.g., the example applications from the course text, or the class project application) that exhibits the required aspects, behaviors, and components and compose your answer from the perspective of that application.
2. Understanding how both JDBC and RMI work, please compare and contrast the two. Your response should include what you think are the key similarities as well as the key differences. Remember to consider how the various access mechanisms for each work as well as how exceptional conditions might manifest themselves. Be thorough, detailed, and original with your response.
3.Which of the four JDBC driver types is best? Why?
Explanation / Answer
1. Thoughts on MVC
MVC is a pretty loosely defined pattern which is open to interpretations of what each of the things in MVC stand for (especially the controller).
On Design Patterns and FXML
JavaFX core FXML based processing is built to be more of a toolkit rather than a complete development framework. The idea being that other frameworks could be layered on top of JavaFX and FXML and the underlying JavaFX/FXML implementations and the controllers for them would not push any kind of agenda or architectural constraints on the higher level frameworks.
As a result, there is a deliberately loose analogy and mapping of core FXML based processing and their controllers to an MVC architecture.
In particular, "MVC" in the context of a web application is interpreted somewhat differently to "MVC" in the context of a thick client (e.g. desktop) application (because a web application has to sit atop the request-response cycle). This is just one approach to implementing MVC in the context of a thick client application, using JavaFX.
2. RMI
- RMI (Remote Method Invocation) extends Java's object model across JVM boundaries.
- RMI allows you to invoke a method on an object in another JVM instance, located either locally or across the network.
- Can pass data (including objects) as arguments to the remote object.
- Can receive primitive types or an object as a return value.
- RMI is a Java to Java solution to distributed computing.
RMI Steps
a.The interface (Summer) must extend java.rmi.Remote.
b.The class that implements the service (SummerServer) must extend java.rmi.server.UnicastRemoteObject.
c.You generate the stub and skeleton classes with rmic:
javac SummerServer
Gives you SummerServer.class
rmic SummerServer
Gives you SummerServer_Stub.class and SummerServer_Skel.class
JDBC
- Standardized SQL lets you talk to databases from different vendors in a uniform way.
- ODBC defined a standard C interface for talking to databases with SQL.
- The JDBC (Java Database Connectivity) library (java.sql) allows you to use SQL to talk to databases from a Java program.
- The java.sql calls go through a JDBC driver.
- JDK comes with a JDBC to ODBC bridge.
- DB vendors are creating native JDBC drivers; JDBC drivers that talk over a network also exist.
JDBC Steps
a.On your system or network:
-First you need a database.
-Set up the system so that you can access the database via a JDBC driver.
b.In your Java program:
-Load the JDBC driver class, which will register itself.
-Connect to the datasource through a "database URL" of the form jdbc.subprotocol.name
-Execute SQL statements.
-Close the connection.
3. Type 1 JDBC Driver
JDBC-ODBC Bridge driver
The Type 1 driver translates all JDBC calls into ODBC calls and sends them to the ODBC driver. ODBC is a generic API. The JDBC-ODBC Bridge driver is recommended only for experimental use or when no other alternative is available.
Advantage
The JDBC-ODBC Bridge allows access to almost any database, since the database's ODBC drivers are already available.
Disadvantages
1. Since the Bridge driver is not written fully in Java, Type 1 drivers are not portable.
2. A performance issue is seen as a JDBC call goes through the bridge to the ODBC driver, then to the database, and this applies even in the reverse process. They are the slowest of all driver types.
Type 2 JDBC Driver
Native-API/partly Java driver
The distinctive characteristic of type 2 jdbc drivers are that Type 2 drivers convert JDBC calls into database- specific calls i.e. this driver is specific to a particular database. Some distinctive characteristic of type 2 jdbc drivers are shown below. Example: Oracle will have oracle native api.
Advantage
The distinctive characteristic of type 2 jdbc drivers are that they are typically offer better performance than the JDBC-ODBC Bridge as the layers of communication (tiers) are less than that of Type
1 and also it uses Native api which is Database specific.
Disadvantage
1. Native API must be installed in the Client System and hence type 2 drivers cannot be used for the Internet.
2. Like Type 1 drivers, it’s not written in Java Language which forms a portability issue.
Type 3 JDBC Driver
All Java/Net-protocol driver
Type 3 database requests are passed through the network to the middle-tier server. The middle-tier then translates the request to the database. If the middle-tier server can in turn use Type1, Type 2 or Type 4 drivers.
Advantage
1. This driver is server-based, so there is no need for any vendor database library to be present on client machines.
2. This driver is fully written in Java and hence Portable. It is suitable for the web.
Disadvantage
It requires another server application to install and maintain. Traversing the recordset may take longer, since the data comes through the backend server.
Type 4 JDBC Driver
Native-protocol/all-Java driver
The Type 4 uses java networking libraries to communicate directly with the database server.
Advantage
The major benefit of using a type 4 jdbc drivers are that they are completely written in Java to achieve platform independence and eliminate deployment administration issues. It is most suitable for the web.
Disadvantage
With type 4 drivers, the user needs a different driver for each database.
Which Driver should be Used?
If you are accessing one type of database, such as Oracle, Sybase, or IBM, the preferred driver type is 4.
If your Java application is accessing multiple types of databases at the same time, type 3 is the preferred driver.
Type 2 drivers are useful in situations, where a type 3 or type 4 driver is not available yet for your database.
The type 1 driver is not considered a deployment-level driver, and is typically used for development and testing purposes only.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.