Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
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)2023 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-02-21
*
* 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.tomcat;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ConnectException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
import org.kawanfw.sql.api.server.DatabaseConfigurationException;
import org.kawanfw.sql.servlet.ServerSqlManager;
import org.kawanfw.sql.servlet.injection.properties.ConfProperties;
import org.kawanfw.sql.servlet.injection.properties.ConfPropertiesManager;
import org.kawanfw.sql.servlet.injection.properties.ConfPropertiesStore;
import org.kawanfw.sql.servlet.injection.properties.AdvancedServletAceQLCallNameGetter;
import org.kawanfw.sql.servlet.injection.properties.PropertiesFileStore;
import org.kawanfw.sql.servlet.injection.properties.PropertiesFileUtil;
import org.kawanfw.sql.tomcat.util.PortSemaphoreFile;
import org.kawanfw.sql.util.FrameworkDebug;
import org.kawanfw.sql.util.SqlTag;
/**
* Configures Tomcat from the properties file and start it.
*
* @author Nicolas de Pomereu
*
*/
public class TomcatStarter {
private static boolean DEBUG = FrameworkDebug.isSet(TomcatStarter.class);
public static String CR_LF = System.getProperty("line.separator");
/** The file containing all the properties for the Server Session */
private File propertiesFile = null;
/** The host of the Web Server */
private String host = null;
/** The port of the Web Server */
private int port = -1;
/** To use to replace the display of a password */
public static final String MASKED_PASSWORD = "********";
/**
* Constructor
*
* @param host the host of the Web Server
* @param port the port of the Web Server
* @param propertiesFile properties file to use for configuration of the Web
* Server
*
*/
public TomcatStarter(String host, int port, File propertiesFile) {
if (host == null) {
throw new IllegalArgumentException("Server host is null!");
}
if (port <= 0) {
throw new IllegalArgumentException("Server port <= 0!");
}
if (propertiesFile == null) {
throw new IllegalArgumentException("Server properties file is null!");
}
this.host = host;
this.port = port;
this.propertiesFile = propertiesFile;
}
/**
* Start the server
*
* @throws IOException
* @throws LifecycleException
* @throws ConnectException
* @throws DatabaseConfigurationException
* @throws SQLException
*/
public void startTomcat()
throws IOException, ConnectException, DatabaseConfigurationException, LifecycleException, SQLException {
Tomcat tomcat = new Tomcat();
try {
startTomcat(tomcat);
} finally {
try {
tomcat.stop();
tomcat.destroy();
} catch (Exception e) {
e.printStackTrace(System.out);
e.printStackTrace();
}
}
}
private void startTomcat(Tomcat tomcat) throws IOException, ConnectException, LifecycleException,
MalformedURLException, DatabaseConfigurationException, SQLException {
TomcatSqlModeStore.setTomcatEmbedded(true);
// To be done at first, everything depends on ir.
PropertiesFileStore.set(propertiesFile);
TomcatStarterMessages.printBeginMessage();
System.out.println(TomcatStarterUtil.getJavaInfo());
System.out.println(SqlTag.SQL_PRODUCT_START + " " + "Using Properties File: ");
System.out.println(SqlTag.SQL_PRODUCT_START + " -> " + propertiesFile);
Properties properties = PropertiesFileUtil.getProperties(propertiesFile);
debug("");
if (DEBUG) {
for (Map.Entry