Bug #116295 Example relies on deprecated method

Submitted: 4 Oct 2024 5:32 Modified: 27 Nov 2025 17:50
Reporter: Daniël van Eeden Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Documentation Severity:S3 (Non-critical)
Version:9.0.0 OS:Any
Assigned to: CPU Architecture:Any

[4 Oct 2024 5:32] Daniël van Eeden
Description:
https://dev.mysql.com/doc/connector-j/en/connector-j-usagenotes-connect-drivermanager.html... has this:

```
Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
```

However `newInstance()` has been deprecated for a while (see also https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html#newInstance-- )

How to repeat:
See description

Suggested fix:
Replace with:

```
Class.forName("com.mysql.cj.jdbc.Driver").getDeclaredConstructor().newInstance();
```
[4 Oct 2024 5:51] MySQL Verification Team
Hello Daniël,

Thank you for the report and feedback.

regards,
Umesh
[27 Nov 2025 17:50] Edward Gilmore
Documentation updated as requested.
Thank you for the bug report.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.