-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support external driver; support mysql connector
- Loading branch information
Showing
8 changed files
with
109 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/de/xab/ping/connector/impl/BuiltinConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package de.xab.ping.connector.impl; | ||
|
||
public class BuiltinConnector extends CustomConnector { | ||
|
||
@Override | ||
protected String parseDriver(String url, String driverFolder) { | ||
return "drivers/" + url.split(":")[1] + "/"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/de/xab/ping/connector/impl/ExternalConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package de.xab.ping.connector.impl; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.MalformedURLException; | ||
import java.net.URI; | ||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class ExternalConnector extends CustomConnector { | ||
protected ClassLoader initClassloader(String url, String driverFolder) throws IOException { | ||
List<URL> list; | ||
URI uri = new File(driverFolder).toURI(); | ||
Path dirPath = Paths.get(uri); | ||
list = Files.list(dirPath).map(path -> { | ||
try { | ||
return path.toUri().toURL(); | ||
} catch (MalformedURLException e) { | ||
e.printStackTrace(); | ||
return null; | ||
} | ||
}).collect(Collectors.toList()); | ||
URL[] array = new URL[]{}; | ||
array = list.toArray(array); | ||
return new URLClassLoader(array); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/de/xab/ping/connector/impl/MySQLConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.xab.ping.connector.impl; | ||
|
||
import java.util.Properties; | ||
|
||
public class MySQLConnector extends BuiltinConnector { | ||
|
||
@Override | ||
protected String getDriverClass(Properties properties) { | ||
return "com.mysql.cj.jdbc.Driver"; | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
src/main/resources/META-INF/ping/de.xab.ping.connector.DBConnector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
external=de.xab.ping.connector.impl.ExternalConnector | ||
h2=de.xab.ping.connector.impl.H2Connector | ||
postgresql=de.xab.ping.connector.impl.PostgreSQLConnector | ||
hive=de.xab.ping.connector.impl.HiveConnector | ||
impala=de.xab.ping.connector.impl.ImpalaConnector | ||
prestodb=de.xab.ping.connector.impl.PrestoDBConnector | ||
prestodb=de.xab.ping.connector.impl.PrestoDBConnector | ||
mysql=de.xab.ping.connector.impl.MySQLConnector |