Open Scarpah600 opened 6 years ago
package br.com.Jc1.factory; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class ConexaoFactory { private static final String USUARIO = "root"; private static final String SENHA = "asmn*pozx80"; private static final String URL = "jdbc:mysql://localhost:3306/dtb_filmes"; public static Connection conectar() throws SQLException { Connection conexao = DriverManager.getConnection(URL, USUARIO, SENHA); return conexao; } public static void main(String[] args) throws SQLException { try { Connection conexao = ConexaoFactory.conectar(); System.out.println("Conectado com sucesso!!"); } catch (SQLException ex) { ex.printStackTrace(); System.out.println("Conexao Falhou"); } } }