When I remove Connection netbeans say me "You should add Connection cast" but after add, it gives me class cast exception.
How can ı solve this.
>Solution :
The exception tells all
The DriverManager.getConnection returns a java.mysql.connection or more specifically a com.mysql.cj.jdbc.ConnectionImpl when using Mysql
And you have imported a com.sun.jdi.connect.spi.Connection which is nothing related to
Use the right import and it’ll be good
import com.mysql.cj.jdbc.ConnectionImpl; // REMOVE
import java.mysql.Connection; // ADD