Run a SQL Script
Simple example of run a SQL script
public class ScriptExample { public static void main(String[] args) { // URL to the PHP file on the server String url = "http://localhost/www/projects/Java_Php_DBConnector/RequestHandler.php"; // Get a database instance (singleton) Database db = Database.getInstance(url); // Set Secure protocol ignored to true because we use HTTP protocol in // this example (for security use HTTPS protocol) db.setSecureProtocolIgnored(true); try { db.executeScript("./script.sql"); // The executeScript() method not return anything because if the Script fail, always thrown an Exception. } catch (SQLException | DatabaseException | IOException e) { // Handle exception } } }Go to top