Im learning sql for my school project and i have a problem
Logcat:
ViewPostIme pointer 0
ViewPostIme pointer 1
password :password63826 username:tesr1234
Communications link failure //The Problem
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
code:
password = findViewById(R.id.Password);
username = findViewById(R.id.Username);
button = findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String user1, pass1;
user1 = username.getText().toString();
pass1 = password.getText().toString();
System.out.println("password :"+pass1+" username:"+user1);
String url = "jdbc:mysql://localhost:3306/KonradServer";
String user = "root";
String pass = "Konrad99";
try {
// Verbindung aufbauen
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Connection con = DriverManager.getConnection(url, user, pass);
System.out.println("Verbindung erfolgreich hergestellt");
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}//onclick
});//onclick
I do it on local server just downloaded MySQL Server and Workshop.
SQL connector:
implementation(libs.mysql.connector.java)
Press Button
save Edittext input in Strings
Test Database connection
New contributor
Goodbye is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.