Connection Failures and Data Manipulation at Non-Thread Safe Shared JDBC Connection

Pitfalls of sharing a connection among threads

Here is a review of the potential pitfalls of sharing a single Connection among multiple threads.

  • Committing or rolling back a transaction closes all open ResultSet objects and currently executing Statements, unless you are using held cursors.If one thread commits, it closes the Statements and ResultSets of all other threads using the same connection.
  • Executing a Statement automatically closes any existing open ResultSet generated by an earlier execution of that Statement.If threads share Statements, one thread could close another’s ResultSet.

In many cases, it is easier to assign each thread to a distinct Connection. If thread A does database work that is not transactionally related to thread B, assign them to different Connections. For example, if thread A is associated with a user input window that allows users to delete hotels and thread B is associated with a user window that allows users to view city information, assign those threads to different Connections. That way, when thread A commits, it does not affect any ResultSets or Statements of thread B.

Another strategy is to have one thread do queries and another thread do updates. Queries hold shared locks until the transaction commits in SERIALIZABLE isolation mode; use READ_COMMITTED instead.

Yet another strategy is to have only one thread do database access. Have other threads get information from the database access thread.

Multiple threads are permitted to share a Connection, Statement, or ResultSet. However, the application programmer must ensure that one thread does not affect the behavior of the others.

Recommended Practices (at Oracle)

Here are some tips for avoiding unexpected behavior:

  • Avoid sharing Statements (and their ResultSets) among threads.
  • Each time a thread executes a Statement, it should process the results before relinquishing the Connection.
  • Each time a thread accesses the Connection, it should consistently commit or not, depending on application protocol.
  • Have one thread be the “managing” database Connection thread that should handle the higher-level tasks, such as establishing the Connection, committing, rolling back, changing Connection properties such as auto-commit, closing the Connection, shutting down the database (in an embedded environment), and so on.
  • Close ResultSets and Statements that are no longer needed in order to release resources.
    • -> docs.oracle.com/javadb/10.8.3.0/devguide/cdevconcepts89498.html

 

Ref : oracle.com

Minimum Requirements to Run SQL Server 2012 Express and SQL Server Management Studio

Minimum Requirements to Run SQL Server 2012 Express and SQL Server Management Studio
To begin, please make sure the computer you will be using meets these minimum requirements:

  • Windows 7, Windows Server 2008 R2, Windows Server 2008 Service Pack 2 or Windows Vista (SP2 or later).
  • Internet Explorer 7 or higher. A free download is available from Microsoft — please click here.
  • For 32-bit systems, 1 GHz Intel or compatible processor (2 GHz or higher recommended).
  • For 64-bit systems, 1.4 GHz Intel or compatible processor (2 GHz or higher recommended).
  • 512 MB RAM (1 GB or more is recommended) and at least 2.2 GB of hard disk space for SQL Server Express and related components, plus at least 1 GB for ReliaSoft desktop applications.
  • SVGA display (1,024×768 pixels)
  • Microsoft .NET Framework 3.5 SP1 AND Microsoft .NET Framework 4.0. (.NET 3.5 is no longer included in the SQL Server installation; if it is not already on your computer, a free download is available from Microsoft– please click here. .NET 4.0 is included in the SQL Server 2012 installation files or a free download is also available separately from Microsoft — please click here.)
  • Microsoft Office 2000 or higher (Excel and Word) for automated report generation.

    These requirements satisfy the minimum specifications for SQL Server 2012 Express, SQL Server Management Studio Express and ReliaSoft desktop applications. For more details on Microsoft’s recommended minimum specifications for SQL Server 2012 Express, click here. For more details on our recommended minimum specifications for ReliaSoft applications, click here.