I have read all sorts of positive reasons for using the PreparedStatement type in Java when working with SQL. Does anyone know of any reason why you'd ever choose the Statement type instead?

When you have a query with no parameters that is not meant to be run multiple times in a row.

When you have a query with no parameters that is not meant to be run multiple times in a row.

But why not use the PreparedStatement anyway? It is supposed to be more efficient. Is there any use for a Statement type at all?

It is more "effecient" when you use it repeatedly (without recreating it). Otherwise there is overhead, although normally negligable. Once they are running there is no difference.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.