Category: Establishing a Database Connection

Concurrent Collections and Maps 2 – Concurrency: Part II

Some collections allow the null value, and others do not. All concurrent collections, blocking queues, and concurrent maps do not allow the null value as elements, whereas the copy-on-write collections do. All collections that embody the concept of a set do not allow duplicates—for example, a CopyOnWriteArraySet. All maps (e.g., a ConcurrentHashMap) do not allow

Concurrent Maps – Concurrency: Part II

Concurrent Maps Figure 23.5 shows the inheritance hierarchy of concurrent maps in the java.util .concurrent package. Note the interfaces ConcurrentMap<K,V> and ConcurrentNavigableMap<K,V> that extend the thread-unsafe map interfaces in the java.util package. Their implementations, ConcurrentHashMap<K,V> and ConcurrentSkipListMap<K,V>, provide efficient unsorted and sorted concurrent maps, respectively. The concrete map implementations are summarized in Table 23.9, together

The BlockingQueue Interface – Concurrency: Part II

The BlockingQueue<E> Interface The java.util.concurrent.BlockingQueue interface extends the java.util.Queue interface, as shown in Figure 23.6. Compared to the operations shown for the Queue interface in Table 23.7, the BlockingQueue interface provides new insert and remove operations that can block or can time out—shown in the two rightmost columns in Table 23.13. Classes that implement the

The BlockingDeque Interface – Concurrency: Part II

The BlockingDeque<E> Interface The java.util.concurrent.BlockingDeque interface extends both the java.util.Deque interface and the BlockingQueue interface, as shown in Figure 23.6. Compared to the operations shown for the ConcurrentLinkedDeque interface in Table 23.8, the Blocking-Deque interface provides new insert and remove operations, both at the head and tail of a deque, that can block or can

The CopyOnWriteArraySet Class – Concurrency: Part II

The CopyOnWriteArraySet<E> Class The CopyOnWriteArraySet class implements the java.util.Set interface (§15.4, p. 804). It does not implement any additional methods. Internally it uses a CopyOnWriteArrayList, and therefore shares the same basic properties with the list, except that, being a set, it does not allow duplicates and its elements have no ordering. Example 23.21 illustrates the

Introduction to Relational Databases – Database Connectivity

24.1 Introduction to Relational Databases Relational databases are based on the relational model that provides a standardized way to represent and query data. The data is stored in tables and queried using a query language. Relational Tables Relational databases store information in tables. Each table is designed to represent a business entity that applications need

Basic SQL Statements – Database Connectivity

Basic SQL Statements Structured Query Language (SQL) is used to perform relational database operations. Despite the existence of an ANSI (American National Standards Institute) SQL standard, different database providers may provide SQL implementations that are not exactly the same and may contain nuanced differences and proprietary additions. SQL statements can be logically grouped into a

Basic SQL Statements 2 – Database Connectivity

The UPDATE Statement The UPDATE statement can be used to update specific rows in a table. In other words, this statement modifies zero or more rows in the table: Click here to view code image UPDATEtable_name SETcolumn_name_value_pairs WHERErow_filter; where column_name_value_pairs in the SET clause is a comma-delimited list of pairs of column names and values: Click here

Establishing a Database Connection – Database Connectivity

24.3 Establishing a Database Connection Interaction between the application and the database is in the context of a connection. Database connections are represented by the java.sql.Connection interface. JDBC drivers provide database-specific implementations of this interface. The class java.sql.DriverManager provides the overloaded factory method get-Connection() that initializes and returns a database Connection object. Click here to