com.mysql.cj.xdevapi

## Class SessionFactory

- java.lang.Object
- - com.mysql.cj.xdevapi.SessionFactory

    public class SessionFactory
    extends Object

SessionFactory is used for creation of sessions.

     SessionFactory xFactory = new SessionFactory();

     Session session1 = xFactory.getSession("mysqlx://[user1[:pwd1]@]host1[:port1]/db");
     Session session2 = xFactory.getSession("mysqlx://host2[:port2]/db?user=user2&password=pwd2");
     Session session3 = xFactory.getSession("mysqlx+srv://[user1[:pwd1]@]service_name/db");

### Constructor Summary

Constructors
`SessionFactory()`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected Session` `getSession(ConnectionUrl connUrl)` Creates `Session` by given URL.
`Session` `getSession(Properties properties)` Creates a `Session` using the information contained in the given properties.
`Session` `getSession(String url)` Creates `Session` by given URL.
`protected ConnectionUrl` `parseUrl(String url)` Parses the connection string URL.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SessionFactory

    public SessionFactory()

### Method Detail

#### parseUrl

    protected ConnectionUrl parseUrl(String url)

Parses the connection string URL.

Parameters:
  `url` - the connection string URL.
Returns:
  a `ConnectionUrl` instance containing the URL components.

#### getSession

    protected Session getSession(ConnectionUrl connUrl)

Creates `Session` by given URL.

Parameters:
  `connUrl` - the session `ConnectionUrl`.
Returns:
  a `Session` instance.

#### getSession

    public Session getSession(String url)

Creates `Session` by given URL.

Parameters:
  `url` - the session URL.
Returns:
  a `Session` instance.

#### getSession

    public Session getSession(Properties properties)

Creates a `Session` using the information contained in the given properties.

Parameters:
  `properties` - the `Properties` instance that contains the session components.
Returns:
  a `Session` instance.

Copyright © 2016, 2025, Oracle and/or its affiliates.