Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package conectabanco;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class ConectaBanco {
- private static final String DRIVER = "com.mysql.jdbc.Driver";
- private static final String URL = "jdbc:mysql://localhost:3306/catalogoloja";
- private static final String USUARIO = "root";
- private static final String SENHA = "123";
- public static void main(String[] args) throws ClassNotFoundException {
- //Carrega o Driver
- Class.forName(DRIVER);
- try{
- //Cria a conexão
- Connection conexao = DriverManager.getConnection(URL, USUARIO,SENHA);
- System.out.println("Conectado");
- }catch(SQLException exp){
- System.err.println("Erro "+exp);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement