Advertisement
Guest User

Untitled

a guest
Mar 4th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import java.sql.DriverManager;
  2. import java.sql.SQLException;
  3. import com.mysql.jdbc.Driver;
  4.  
  5. public class ConnectionFactory {
  6. public Connection getConnection() {
  7. System.out.println("Conectando ao banco");
  8. try {
  9. //Class.forName("com.mysql.jdbc.Driver");
  10. DriverManager.registerDriver(new com.mysql.jdbc.Driver()); //Essa linha foi a diferença
  11. return DriverManager.getConnection("jdbc:mysql://localhost/fj21", "root", "simbad");
  12. } catch(SQLException e) {
  13. e.printStackTrace();
  14. throw new RuntimeException(e);
  15.  
  16. }
  17.  
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement