Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package util;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.Scanner;
- /**
- *
- * @author Jivago
- */
- public class ConnBD {
- public static Connection getConnection() {
- String strCon
- = "jdbc:mysql://localhost:3306/aulas";
- try {
- Class.forName("com.mysql.jdbc.Driver");
- Connection con;
- con = DriverManager
- .getConnection(strCon, "root", "");
- return con;
- } catch (SQLException ex) {
- System.out.println("Erro conectando"
- + "no banco de dados"
- + ex.getMessage());
- } catch (ClassNotFoundException ex) {
- System.out.println(ex.getMessage());
- }
- return null;
- }
- }
Add Comment
Please, Sign In to add comment