Changeset 34897 for gs2-extensions/tipple-bridge
- Timestamp:
- 2021-02-18T16:01:53+13:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/tipple-bridge/trunk/src/src/main/java/sqlCli.java
r34896 r34897 9 9 import com.google.gson.Gson; 10 10 import java.io.FileWriter; 11 import java.util.concurrent.Callable; 11 12 12 13 /* … … 25 26 */ 26 27 @Command (name="sqlCli", description = "Arguments for database connection", mixinStandardHelpOptions = true) 27 public class sqlCli implements Runnable{28 public class sqlCli implements Callable<Integer> { 28 29 //our cli arguments 29 30 … … 54 55 String projectID; 55 56 56 57 /*58 this parameter can be read in at any point on the options line.59 but that's only because it's the only parameter at the moment.60 If we add more parameters, will either have to put them next to each other61 OR add in indexes62 https://picocli.info/quick-guide.html#_options_and_parameters63 */64 @Parameters(description = "Name of the output JSON file. E.g. yourFileName.json")65 String jsonOutputFile;66 67 57 @Option(names = {"--host"}, description = "Type of host e.g. localhost ", 68 58 required = true, defaultValue = "localhost") 69 59 String host; 70 60 71 public void run(){ 61 /* 62 this parameter can be read in at any point on the options line. 63 but that's only because it's the only parameter at the moment. 64 If we add more parameters, will either have to put them next to each other 65 OR add in indexes 66 https://picocli.info/quick-guide.html#_options_and_parameters 67 */ 68 @Parameters(description = "Name of the output JSON file. E.g. yourFileName.json") 69 String jsonOutputFile; 70 71 public Integer call(){ 72 72 //if it doesn't end with ... 73 73 if(!jsonOutputFile.endsWith(".json")){ … … 75 75 System.out.println("The file to save the output to must be a .json file."); 76 76 //exit code other than 0 means it's not fine. 77 System.exit(1); 78 } 79 //else we're good to go. 80 databaseConnect(userName, password, port, dbName, projectID, jsonOutputFile, host); 77 return 1; 78 } 79 //else we're good to go. 80 // databaseConnect(userName, password, port, dbName, projectID, jsonOutputFile, host); 81 int status = databaseConnect(userName, password, port, dbName, projectID, jsonOutputFile, host); 82 return status; 81 83 } 82 84 … … 87 89 88 90 89 private static voiddatabaseConnect(String user, String pass, int port, String dbName,91 private static int databaseConnect(String user, String pass, int port, String dbName, 90 92 String projectID, String fileName, String host){ 91 93 Connection conn; 92 94 Statement stmt; 93 95 int returnStatus = 0; 94 96 // String dbUrl = "jdbc:mysql://localhost:" + port +"/"+ dbName; 95 97 … … 215 217 System.out.println(" -'Database name' "); 216 218 } 219 returnStatus = 1; 217 220 218 221 } … … 222 225 //print out wrong username or password instead of the stack trace? 223 226 System.out.println("encountered error"); 224 225 } 227 returnStatus = 2; 228 } 229 return returnStatus; 226 230 } 227 231 }
Note:
See TracChangeset
for help on using the changeset viewer.