JPA or JDBC, how are they different?

In layman’s terms: JDBC is a standard for Database Access JPA is a standard for ORM JDBC is a standard for connecting to a DB directly and running SQL against it – e.g SELECT * FROM USERS, etc. Data sets can be returned which you can handle in your app, and you can do all … Read more

What does java:comp/env/ do?

Quoting https://web.archive.org/web/20140227201242/http://v1.dione.zcu.cz/java/docs/jndi-1.2/tutorial/beyond/misc/policy.html At the root context of the namespace is a binding with the name “comp”, which is bound to a subtree reserved for component-related bindings. The name “comp” is short for component. There are no other bindings at the root context. However, the root context is reserved for the future expansion of the policy, specifically … Read more

What kind of Java type is “[B”?

That my friend is an array of bytes. In JNI, [B is used to describe an array ([) of bytes (B). An array of ints is [I etc. You can get a bit more information on field descriptors here:JNI Types and Data Structures (Table 3-2 should be what you are looking for).

Cannot issue data manipulation statements with executeQuery()

To manipulate data you actually need executeUpdate() rather than executeQuery(). Here’s an extract from the executeUpdate() javadoc which is already an answer at its own: Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.

Getting java.sql.SQLException: Operation not allowed after ResultSet closed

The problem is with the way you fetch data in getStuff(). Each time you visit getStuff() you obtain a fresh ResultSet but you don’t close it. This violates the expectation of the Statement class (see here – http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html): By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is … Read more