I have Java code that connects to an SQL server DB but I cannot access the DB from the Java app. When I compiled the connection was successfully reported but I cannot execute any SQL statement. The error is that:
run:
The SQL connection was successful.
Exception in thread "main" java.lang.ClassCastException: com.microsoft.sqlserver.jdbc.SQLServerStatement cannot be cast to java.beans.Statement
at project.getConnection.connection(getConnection.java:73)
at project.Main.main(Main.java:31)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
here is the line 73 if i remove the (Statement)
s = (Statement) connection.createStatement();