you can have a class from:
Conection cn;
cn=DriverManager.getConnection("jdbc:mysql://localhot:3306/BD","root","pass");
// and from another class, which is the one that inserts a record, call the connection variable "cn"? The idea is to have the connection class separated from the class that makes the insert.
PreparedStatement ST;
ST=cn.preparedStatement("");
// I get an error that does not find "cn" as variable q contains the connection, try also importing the claSe but in success.