Skip to main content

Menu

Webinar

Built for the Agentic Era: Introducing MariaDB Enterprise Platform 2027

Register now

Releases

What’s new in MariaDB Connector/J 4.0

By Diego Dupin

10 min read
Share

Key takeaways

  • Instant performance gains: Upgrading gives your application an immediate speed boost of up to 15% on typical workloads without requiring a single code change.
  • Effortless built-in security: All connections are now automatically encrypted and verified by default, giving you ironclad data protection with zero manual configuration.
  • Smarter handling of large files: New network streaming lets you process massive documents smoothly without draining server memory or risking application crashes.
jdbc:mariadb://localhost:3306/db?user=app&password=secret&sslMode=disable
jdbc:mariadb:sequential://db1,db2,db3/db?user=app&password=secret&sslMode=allow
try (PreparedStatement ps = con.prepareStatement(
        "SELECT name, content FROM documents WHERE id = ?")) {
  ps.setFetchSize(Integer.MIN_VALUE);          // sequential access
  ps.setLong(1, 42);
  try (ResultSet rs = ps.executeQuery()) {
    if (rs.next()) {
      String name = rs.getString(1);           // read columns in index order
      try (InputStream in = rs.getBinaryStream(2)) {
        Files.copy(in, Path.of("/tmp", name));  // bytes flow from the socket to the file
      }
    }
  }
}
<dependency>
  <groupId>org.mariadb.jdbc</groupId>
  <artifactId>mariadb-java-client-aws</artifactId>
  <version>4.0.0</version>
</dependency>
jdbc:mariadb://mydb.123456789012.eu-west-1.rds.amazonaws.com/db?user=iam_user&credentialType=AWS-IAM&roleArn=arn:aws:iam::123456789012:role/db-reader
jdbc:mariadb://localhost/db?user=app&permitNoResults=true
jdbc:mariadb:///db?user=app&localSocket=C:\\Users\\app\\tunnel.sock
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>4.0.0</version>
</dependency>