Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Sidney Castro
Added: Oct 6, 2018 11:54 PM
Views: 2
Tags: no tags
Teste
  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 java.sql.Connection;
  9. import java.sql.DriverManager;
  10. import java.sql.SQLException;
  11.  
  12. /**
  13.  *
  14.  * @author Sidney
  15.  */
  16. public class Aluno {
  17.  
  18.     /**
  19.      * @param args the command line arguments
  20.      */
  21.     public static void main(String[] args) {
  22.         Aluno al = new Aluno();
  23.         System.out.println(al.abreBanco());
  24.     }
  25.  
  26.     public Connection abreBanco() {
  27.         String url = "jdbc:mysql://104.196.222.250/funcao";
  28.         String usuario = "aluno";
  29.         String senha = "aluno";
  30.  
  31.         try {
  32.             Connection con = DriverManager.getConnection(url, usuario, senha);
  33.             return con;
  34.         } catch (SQLException ex) {
  35.             ex.printStackTrace();
  36.             return null;
  37.         }
  38.     }
  39.  
  40. }
  41.