Created the login example

This commit is contained in:
mathias 2021-08-25 14:30:43 +02:00
parent 9ef0fbcba4
commit 3a21863990
No known key found for this signature in database
GPG Key ID: 8950DF62139C852A

View File

@ -0,0 +1,32 @@
import de.gnmyt.sqltoolkit.drivers.MySQLConnection;
import de.gnmyt.sqltoolkit.types.LoginParam;
import java.util.Arrays;
public class LoginExample {
public static void main(String[] args) {
// First we can define the mysql server data into some variables
String hostname = "localhost";
String username = "root";
String password = "password";
String database = "database";
// Then we need to create a connection
MySQLConnection connection = new MySQLConnection(hostname, username, password, database, // Here you need to provide your mysql server data
LoginParam.AUTO_RECONNECT); // You can set login parameters in the constructor
// You can also set the connection string manually (before connecting)
connection.updateConnectionString(LoginParam.AUTO_RECONNECT,
LoginParam.USE_SSL,
LoginParam.UTF8_ENCODING);
// Now you can connect to the database
connection.connect();
// If you want to you can list all login parameters
Arrays.stream(LoginParam.values()).forEach(System.out::println);
}
}