The prototype of PreparedStatement is public interface PreparedStatement extends Statement, which is an interface. You need to implement all interfaces
Here you use the try-with-resource syntax added in recent versions of Java. This syntax requires that the variables defined within parentheses be the Closeable interface first. If the class library where PreparedSatement is used is older, it may not implement this interface.
Maybe the syntax you are using exceeds the version of the JRE library you reference.
When I look at the error report, I see that the try with resources syntax of jdk7 is used. The resources in the try brackets must implement AutoCloseable, and PrepareStatement does not implement the AutoCloseable interface. Let’s use it differently, try-finally
The prototype of PreparedStatement is public interface PreparedStatement extends Statement, which is an interface. You need to implement all interfaces
You need to provide the code of the error line to confirm. Most likely you have a few lines of code like this:
try(
PreparedStatement pstmt = conn.prepareSatement("select ...");
){
...
}
Here you use the try-with-resource syntax added in recent versions of Java. This syntax requires that the variables defined within parentheses be the Closeable interface first. If the class library where PreparedSatement is used is older, it may not implement this interface.
Maybe the syntax you are using exceeds the version of the JRE library you reference.
When I look at the error report, I see that the try with resources syntax of jdk7 is used. The resources in the try brackets must implement AutoCloseable, and PrepareStatement does not implement the AutoCloseable interface. Let’s use it differently, try-finally