/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package database_con; import java.sql.*; /** * * @author engamir */ public class Database_con { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here System.out.println("MySQL Connect Example."); Connection conn = null; String url = "jdbc:mysql://localhost:3306/"; String dbName = "test"; String driver = "com.mysql.jdbc.Driver"; String userName = "root"; String password = "globalamirtarek"; try { Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection(url+dbName,userName,password); System.out.println("Connected to the database"); conn.close(); System.out.println("Disconnected from database"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException e) { System.out.println(e.getMessage()); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)