Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class BancoTeste {
- public static void main(String args[]) {
- Connection conn = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- conn = DriverManager.getConnection( "jdbc:mysql://localhost/test?user=root&password=default" );
- Statement stm = conn.createStatement();
- System.out.println("Conectou");
- } catch(ClassNotFoundException e) {
- e.printStackTrace();
- } catch(SQLException e) {
- e.printStackTrace();
- } finally {
- try {
- conn.close();
- } catch(SQLException a) {
- System.out.println("Nao fechou conexão");
- a.printStackTrace();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment