×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Sidney Castro
Added: Oct 7, 2018 12:08 AM
Views: 3435
Tags: no tags
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package aluno;
  7.  
  8. import gui.Menu;
  9. import java.sql.Connection;
  10. import java.sql.DriverManager;
  11. import java.sql.SQLException;
  12.  
  13. /**
  14.  *
  15.  * @author Sidney
  16.  */
  17. public class Aluno {
  18.  
  19.     /**
  20.      * @param args the command line arguments
  21.      */
  22.     public static void main(String[] args) {
  23.         Aluno al = new Aluno();
  24.         Connection con = al.abreBanco();
  25.         if (con!=null) {
  26.             Menu mn = new Menu(con);
  27.             mn.setVisible(true);
  28.         }
  29.     }
  30.  
  31.     public Connection abreBanco() {
  32.         String url = "jdbc:mysql://104.196.222.250/funcao";
  33.         String usuario = "aluno";
  34.         String senha = "aluno";
  35.  
  36.         try {
  37.             Connection con = DriverManager.getConnection(url, usuario, senha);
  38.             return con;
  39.         } catch (SQLException ex) {
  40.             ex.printStackTrace();
  41.             return null;
  42.         }
  43.     }
  44.  
  45. }
  46.