SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main.resources.domain.receiver;
  2.  
  3. import main.resources.persistency.DynamicDao;
  4. import main.resources.persistency.DynamicDaoOracle;
  5.  
  6. import java.sql.SQLException;
  7.  
  8. public class ExecuteService {
  9.  
  10.     /**
  11.      * Executes given SQL code on given database
  12.      * @param code SQL query to be executed
  13.      * @param databaseType
  14.      * @param url of the database
  15.      * @return true if code was successfully executed, false if not
  16.      */
  17.     public boolean executeCode(String code, String databaseType, String url, String username, String password)
  18.             throws ClassNotFoundException, SQLException {
  19.         DynamicDao dynamicDao;
  20.  
  21.         if(databaseType.toUpperCase().equals("ORACLE")) {
  22.             dynamicDao = new DynamicDaoOracle();
  23.         } else {
  24.             System.out.println("Invalid or unsupported database type");
  25.             return false;
  26.         }
  27.  
  28.         dynamicDao.setTargetUrl(url);
  29.         dynamicDao.setTargetUsername(username);
  30.         dynamicDao.setTargetPassword(password);
  31.  
  32.         return dynamicDao.executeCode(code);
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top