22 * The contents of this file are subject to the license and copyright
33 * detailed in the LICENSE file at the root of the source
44 * tree and available online at
5- *
5+ * <p>
66 * https://github.com/keeps/db-preservation-toolkit
77 */
88/**
3030import com .databasepreservation .modules .mysql .MySQLHelper ;
3131import com .databasepreservation .utils .RemoteConnectionUtils ;
3232
33+ import static com .databasepreservation .modules .mysql .Constants .MYSQL_DRIVER_CLASS_NAME ;
34+
3335/**
3436 * @author Luis Faria
3537 */
@@ -53,30 +55,6 @@ public class MySQLJDBCExportModule extends JDBCExportModule {
5355
5456 private final boolean ssh ;
5557
56- /**
57- * MySQL JDBC export module constructor
58- *
59- * @param hostname
60- * the hostname of the MySQL server
61- * @param database
62- * the name of the database to import from
63- * @param username
64- * the name of the user to use in connection
65- * @param password
66- * the password of the user to use in connection
67-
68- public MySQLJDBCExportModule(String hostname, String database, String username, String password, boolean encrypt) {
69- super("com.mysql.jdbc.Driver", createConnectionURL(hostname, -1, database, username, password, encrypt), new MySQLHelper());
70- this.hostname = hostname;
71- this.port = -1;
72- this.database = database;
73- this.username = username;
74- this.password = password;
75- this.encrypt = encrypt;
76- this.ignoredSchemas = new TreeSet<String>(Arrays.asList(IGNORED_SCHEMAS));
77- }
78- */
79-
8058 /**
8159 * MySQL JDBC export module constructor
8260 *
@@ -91,8 +69,9 @@ public MySQLJDBCExportModule(String hostname, String database, String username,
9169 * @param password
9270 * the password of the user to use in connection
9371 */
94- public MySQLJDBCExportModule (String hostname , int port , String database , String username , String password , boolean encrypt ) {
95- super ("com.mysql.jdbc.Driver" , createConnectionURL (hostname , port , database , username , password , encrypt ),
72+ public MySQLJDBCExportModule (String hostname , int port , String database , String username , String password ,
73+ boolean encrypt ) {
74+ super (MYSQL_DRIVER_CLASS_NAME , createConnectionURL (hostname , port , database , username , password , encrypt ),
9675 new MySQLHelper ());
9776 this .hostname = hostname ;
9877 this .port = port ;
@@ -104,9 +83,11 @@ public MySQLJDBCExportModule(String hostname, int port, String database, String
10483 this .ssh = false ;
10584 }
10685
107- public MySQLJDBCExportModule (String hostname , int port , String database , String username , String password , boolean encrypt , boolean ssh , String sshHost , String sshUser , String sshPassword , String sshPortNumber ) throws ModuleException {
108- super ("com.mysql.jdbc.Driver" , createConnectionURL (hostname , port , database , username , password , encrypt ),
109- new MySQLHelper (), ssh , sshHost , sshUser , sshPassword , sshPortNumber );
86+ public MySQLJDBCExportModule (String hostname , int port , String database , String username , String password ,
87+ boolean encrypt , boolean ssh , String sshHost , String sshUser , String sshPassword , String sshPortNumber )
88+ throws ModuleException {
89+ super (MYSQL_DRIVER_CLASS_NAME , createConnectionURL (hostname , port , database , username , password , encrypt ),
90+ new MySQLHelper (), ssh , sshHost , sshUser , sshPassword , sshPortNumber );
11091 this .hostname = hostname ;
11192 this .port = port ;
11293 this .database = database ;
@@ -117,15 +98,16 @@ public MySQLJDBCExportModule(String hostname, int port, String database, String
11798 this .ssh = ssh ;
11899 }
119100
120- public static String createConnectionURL (String hostname , int port , String database , String username ,
121- String password , boolean encrypt ) {
101+ public static String createConnectionURL (String hostname , int port , String database , String username , String password ,
102+ boolean encrypt ) {
122103 return "jdbc:mysql://" + hostname + (port >= 0 ? ":" + port : "" ) + "/" + database + "?" + "user=" + username
123104 + "&password=" + password + "&useSSL=" + encrypt + "&rewriteBatchedStatements=true" ;
124105 }
125106
126107 public String createConnectionURL (String databaseName ) {
127108 if (ssh ) {
128- return createConnectionURL (hostname , RemoteConnectionUtils .getLocalPort (), databaseName , username , password , encrypt );
109+ return createConnectionURL (hostname , RemoteConnectionUtils .getLocalPort (), databaseName , username , password ,
110+ encrypt );
129111 } else {
130112 return createConnectionURL (hostname , port , databaseName , username , password , encrypt );
131113 }
0 commit comments