{"record":{"id":"2b5bbbdc830cefad","repo":"apache/shardingsphere","slug":"0-2b5bbb","errorCode":"0","errorMessage":"Can not register driver.","messagePattern":"Can not register driver\\.","errorType":"exception","errorClass":"DriverRegisterException","httpStatus":null,"severity":"critical","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/ShardingSphereDriver.java","lineNumber":50,"sourceCode":"/**\n * ShardingSphere driver.\n */\n@SuppressWarnings(\"UseOfJDBCDriverClass\")\npublic final class ShardingSphereDriver implements Driver {\n    \n    private static final String DRIVER_URL_PREFIX = \"jdbc:shardingsphere:\";\n    \n    private static final int MAJOR_DRIVER_VERSION = 5;\n    \n    private static final int MINOR_DRIVER_VERSION = 5;\n    \n    private static final DriverDataSourceCache DATA_SOURCE_CACHE = new DriverDataSourceCache();\n    \n    static {\n        try {\n            DriverManager.registerDriver(new ShardingSphereDriver());\n        } catch (final SQLException ex) {\n            throw new DriverRegisterException(ex);\n        }\n    }\n    \n    @HighFrequencyInvocation(canBeCached = true)\n    @Override\n    public Connection connect(final String url, final Properties info) throws SQLException {\n        return acceptsURL(url) ? DATA_SOURCE_CACHE.get(url, DRIVER_URL_PREFIX).getConnection() : null;\n    }\n    \n    @Override\n    public boolean acceptsURL(final String url) {\n        return null != url && url.startsWith(DRIVER_URL_PREFIX);\n    }\n    \n    @Override\n    public DriverPropertyInfo[] getPropertyInfo(final String url, final Properties info) {\n        return new DriverPropertyInfo[0];\n    }","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/ShardingSphereDriver.java#L32-L68","documentation":"DriverRegisterException (an RuntimeException) thrown from ShardingSphereDriver's static initializer when DriverManager.registerDriver(new ShardingSphereDriver()) fails with SQLException. Because it happens in a <clinit> block, it surfaces as ExceptionInInitializerError followed by NoClassDefFoundError on later class use. Registration almost never fails unless the JDBC infrastructure itself is broken.","triggerScenarios":"First class-loading of ShardingSphereDriver (e.g. Class.forName(\"org.apache.shardingsphere.driver.ShardingSphereDriver\") or DriverManager scanning) while DriverManager.registerDriver throws — typically a damaged JDK/JDBC setup, a SecurityManager refusing driver registration, or a conflicting/corrupted driver jar on the classpath.","commonSituations":"Corrupted or incomplete ShardingSphere jdbc jar (missing classes); a custom SecurityManager or hardened container blocking DriverManager registration; shaded/fat-jar builds that mangle the driver classes; JDK migration issues; duplicated incompatible driver versions resolved by the classpath.","solutions":["Verify the ShardingSphere jdbc artifact and its dependencies are complete and match your version (mvn dependency:tree; check for jar corruption).","Remove duplicate/conflicting shardingsphere-driver jars from the classpath.","If a SecurityManager is active, grant the permission needed for DriverManager.registerDriver or disable it.","Rebuild/replace the fat jar with a correct shading configuration that keeps META-INF/services and driver classes intact."],"exampleFix":"// before\nclasspath: shardingsphere-jdbc-5.5.0.jar (corrupted) -> ExceptionInInitializerError\n// after\nclasspath: verified shardingsphere-jdbc-5.5.0.jar + aligned infra modules\nClass.forName(\"org.apache.shardingsphere.driver.ShardingSphereDriver\");","handlingStrategy":"validation","validationCode":"try { Class.forName(\"org.apache.shardingsphere.driver.ShardingSphereDriver\"); } catch (Throwable t) { failFast(\"driver jar broken: \" + t); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin one shardingsphere-jdbc version and verify jar integrity at build time","Check dependency tree for duplicate driver artifacts","Smoke-test driver registration at startup, not first query"],"tags":["jdbc","driver-registration","classpath","static-initializer"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}