connect method

  1. @override
Future<bool> connect({
  1. required String ip,
  2. required String port,
  3. required String databaseName,
  4. required String username,
  5. required String password,
  6. int timeoutInSeconds = 30,
})
override

Connects to the SQL Server database.

The required parameters are the IP address, port, database name, username, password, and an optional timeout in seconds.

Implementation

@override
Future<bool> connect({
  required String ip,
  required String port,
  required String databaseName,
  required String username,
  required String password,
  int timeoutInSeconds = 30,
}) async {
  try {
    var invokeMethod = await methodChannel.invokeMethod<bool>(
          'connectDb',
          {
            'url': "jdbc:jtds:sqlserver://$ip:$port/$databaseName",
            'username': username,
            'password': password,
            'timeoutInSeconds': timeoutInSeconds,
          },
        ) ??
        false;
    return invokeMethod;
  } catch (e) {
    rethrow;
  }
}