
org.kawanfw.sql.api.util.webserver.WebServerUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aceql-http Show documentation
Show all versions of aceql-http Show documentation
AceQL HTTP is a framework of REST like http APIs that allow to access to remote SQL databases over http from any device that supports http.
AceQL HTTP is provided with four client SDK:
- The AceQL C# Client SDK allows to wrap the HTTP APIs using Microsoft SQL Server like calls in their code, just like they would for a local database.
- The AceQL Java Client SDK allows to wrap the HTTP APIs using JDBC calls in their code, just like they would for a local database.
- The AceQL Python Client SDK allows SQL calls to be encoded with standard unmodified DB-API 2.0 syntax
/*
* Copyright (c)2022 KawanSoft S.A.S. All rights reserved.
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file in the project's root directory.
*
* Change Date: 2026-11-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2.0 of the Apache License.
*/
package org.kawanfw.sql.api.util.webserver;
import java.io.IOException;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.kawanfw.sql.util.SqlTag;
/**
* Util methods for WebServer class.
* @author Nicolas de Pomereu
*
*/
public class WebServerUtil {
/** Universal and clean line separator */
private static String CR_LF = System.getProperty("line.separator");
/**
*
*/
public static void systemExitWrapper(int value) {
System.exit(-1);
}
/**
* @param e
*/
public static void printCauseException(IOException e) {
if (e.getCause() == null) {
e.printStackTrace();
} else {
e.getCause().printStackTrace();
}
}
/**
* Prints usage
*
* @param options the CLI Options
*/
public static void printUsage(Options options) {
// automatically generate the help statement
HelpFormatter formatter = new HelpFormatter();
formatter.setWidth(400);
String fromAceqlServerScript = System.getProperty("from.aceql-server.script");
String help = null;
if (fromAceqlServerScript != null && fromAceqlServerScript.equals("true")) {
help = "aceql-server -start -host -port -properties " + CR_LF + "or " + CR_LF
+ "-stop -port ";
} else {
help = "java org.kawanfw.sql.WebServer -start -host -port -properties " + CR_LF
+ "or " + CR_LF + "-stop -port ";
}
formatter.printHelp(help, options);
System.out.println();
}
/**
* Displays the error message and exit Java
*
* @param message The message to display before exit
*/
public static void displayErrorAndExit(String message) {
System.err.println(message + " " + SqlTag.PLEASE_CORRECT);
System.err.println();
systemExitWrapper(-1);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy