For mysql
Class.forName("com.mysql.jdbc.Driver");
DriverManager.getConnection(
jdbc:mysql://host:3306/database_name, "userName", "password");
In host,for localmachine use localhost and for other machine use that machine ipaddress
for example(192.168.4.1)
database_name--the database which you want to establish connection.
userName-->userName for the database
password-->password for the same.
Regards,
Sriram.V