Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import com.mysql.jdbc.Driver;
- public class ConnectionFactory {
- public Connection getConnection() {
- System.out.println("Conectando ao banco");
- try {
- //Class.forName("com.mysql.jdbc.Driver");
- DriverManager.registerDriver(new com.mysql.jdbc.Driver()); //Essa linha foi a diferença
- return DriverManager.getConnection("jdbc:mysql://localhost/fj21", "root", "simbad");
- } catch(SQLException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement