Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class Conexao {
- static String status = "";
- public static Connection getConnection(){
- Connection con = null;
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- String url = "jdbc:mysql://127.0.0.1/loja?user=root&password=root";
- con = DriverManager.getConnection(url);
- status = "Conexão Aberta";//muda o status para conexão aberta.
- } catch (ClassNotFoundException e) {
- status = e.getMessage();
- } catch (SQLException e) {
- status = e.getMessage();
- } catch (Exception e){
- status = e.getMessage();
- }
- return con;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement