Properties properties = new java.util.Properties();
properties.put("user", "root");properties.put("password","rootp");
properties.put("useUnicode","true");
properties.put("characterEncoding","utf8");
String databaseURL = "jdbc:mysql://localhost/yourDB";
Connection conn = DriverManager.getConnection(databaseURL, properties);