According to change user and password Java mySql connection will be change
According to change user and password Java mySql connection will be change-
private final String dbURL = "jdbc:mysql://192.168.0.58:3306/gp_rbs";
private final String dbUser = "xxx";
private final String password = "xxx";
**MYsql db open in sqlYog browser :
private final String dbURL = "jdbc:mysql://192.168.0.58:3306/gp_rbs";
private final String dbUser = "xxx";
private final String password = "xxx";
Java and mySql connection :
public class
CopyOfDatabaseConnection_backMySql {
private final String driver = "com.mysql.jdbc.Driver";
//private final
String dbURL =
"jdbc:mysql://192.168.0.123:3306/ati_phsystem";//192.168.0.117
//private final
String dbURL = "jdbc:mysql://localhost:3306/gp_rbs";
private final String dbURL = "jdbc:mysql://192.168.0.58:3306/gp_rbs";
private final String dbUser = "kaniz";
private final String password = "kaniz";
Connection
connect = null;
public Connection
connectDB() {
try {
Class.forName("com.mysql.jdbc.Driver");
}
catch
(ClassNotFoundException e) {
System.out.println("Driver Not
Found Exception " + e.getMessage());
}
try {
connect = DriverManager.getConnection(dbURL, dbUser,password);
}
catch (SQLException e) {
System.out.println("DataBase
Connection Exception "
+
e.getMessage());
}
return connect;
}
public static void main(String[] args) throws
ClassNotFoundException {
CopyOfDatabaseConnection_backMySql
db = new
CopyOfDatabaseConnection_backMySql();
Connection
con = db.connectDB();
if (con != null)
System.out.println(" success
");
System.out.println("fail");
}
}
OR Java and mySql connection :
public class
CopyOfDatabaseConnection_backMySql {
private final String driver = "com.mysql.jdbc.Driver";
//private final
String dbURL =
"jdbc:mysql://192.168.0.123:3306/ati_phsystem";//192.168.0.117
//private final
String dbURL = "jdbc:mysql://localhost:3306/gp_rbs";
private final String dbURL = "jdbc:mysql://192.168.0.58:3306/gp_rbs";
private final String dbUser = "kaniz";
private final String password = "";
Connection
connect = null;
public Connection
connectDB() {
try {
Class.forName("com.mysql.jdbc.Driver");
}
catch
(ClassNotFoundException e) {
System.out.println("Driver Not
Found Exception " + e.getMessage());
}
try {
connect = DriverManager.getConnection(dbURL, "kaniz", "");
}
catch (SQLException e) {
System.out.println("DataBase
Connection Exception "
+
e.getMessage());
}
return connect;
}
public static void main(String[] args) throws
ClassNotFoundException {
CopyOfDatabaseConnection_backMySql
db = new
CopyOfDatabaseConnection_backMySql();
Connection
con = db.connectDB();
if (con != null)
System.out.println(" success
");
System.out.println("fail");
}
}
**MYsql db open in sqlYog browser :
No comments:
Post a Comment