Bug #94754 Error getting group, by name, in native pattern class
Submitted: 22 Mar 2019 15:11 Modified: 30 Aug 2020 19:06
Reporter: Marco G Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:8.0.15 OS:Any
Assigned to: CPU Architecture:Any

[22 Mar 2019 15:11] Marco G
Description:
I am using the android SDK 28.

I was trying to use the new library, the old one I can use, but I saw it highly recommended to upgrade the version.

It turns out that I can not start the driver, an exception is thrown, I'm using ORMLite, debugging, I see that it calls the "acceptsUrl" method of the "NonRegisteringDriver"

More in depth, I realized that the problem is actually the android SDK. Example This method, from the ConnectionUrlParser class

public static boolean isConnectionStringSupported (String connString) {
         if (connString == null) {
             throw (WrongArgumentException) ExceptionFactory.createException (WrongArgumentException.class, Messages.getString ("ConnectionString.0"));
         } else {
             Matcher matcher = SCHEME_PTRN.matcher (connString);
             return matcher.matches () && Type.isSupported (decode (matcher.group ("scheme")));
// here an exception is thrown
matcher.group ("scheme") // error
matcher.group (1) // this works
         }
     }

PS: I saw some people in the stackoverflow with the same problem, the same problem in the library, so I decided to open the ticket here, not on android

https://stackoverflow.com/questions/54311335/android-jdbc-connect-mysql-error-when-running...

https://stackoverflow.com/questions/53136585/android-connection-error-java-lang-unsupporte...

How to repeat:

String myJDBC = "jdbc:mysql://myHost:myPort/myBase"; 

call
isConnectionStringSupported(myJDBC);

public static boolean isConnectionStringSupported(String connString) {
//matcher.matches()  == true
//matcher.group("scheme") // this exception
//matcher.group(1) // works
      
}

Suggested fix:
I would suggest using some other library for this, such as apache jakarta, not to be "hostage" to the android SDK changes
[16 Oct 2019 12:40] Alexander Soklakov
Hi Marco,

Is it still a problem with latest Android SDK (https://developer.android.com/studio/releases/platforms#10) ?
[16 Oct 2019 12:47] Marco G
Hi Alexander Soklakov

I can't tell you, I decided to use the old driver for my application mysql-connector-java-5.1.47-bin.jar..
[6 Dec 2019 13:22] Hugs Feli
I have the same problem on android last SDK (29). Unfortunately, using the old 5.X library doesn't work for me.
[6 Dec 2019 13:49] Marco G
Doesn't version 5 work because of your mysql server version?

I opened the ticket in March this year and so far nothing ..
[30 Jul 2020 19:06] Filipe Silva
Can someone confirm if this is still a problem?

According to the android SDK documentation support for named groups should exist since API 26. (https://developer.android.com/reference/java/util/regex/Pattern)

It makes no sense to Matcher.group(String name) still throw a java.lang.UnsupportedOperationException and, if so, a bug should be reported there.
[31 Aug 2020 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".