Я создал один класс сервлетов, и я пытаюсь получить одну запись из Oracle 11g, а также пытаюсь использовать базу данных MySQL, но получаю это исключение: ошибка вывода изображения
Я использую следующие вещи:
WebServer: Tomcat9
JRE: 1.8
Databases: Oracle 11g,MySQL
Вот мой класс сервлетов:
public class EmployeeSearchApp extends HttpServlet{
private static final String EMP_SEARCH_DETAILS = "SELECT EMPMO,ENAME,JOB,SAL,EMPNO FROM EMP WHERE EMPNO=?";
private static final String url="jdbc:oracle:thin:@localhost:1521:orcl";
private static final String userName = "scott";
private static final String password = "tiger";
/*
* private static final String url="jdbc:mysql://localhost:3306/world"; private
* static final String userName = "ram"; private static final String password =
* "padma";
*/
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
PrintWriter pw=null;
int eno=0;
Connection con=null;
PreparedStatement ps=null;
ResultSet rs=null;
try {
//Getting the print Writer Object
pw=res.getWriter();
//Setting the content type
res.setContentType("text/html");
//getting the parameter value
eno=Integer.parseInt(req.getParameter("eno"));
//JDBC code
//Registering JDBC driver
Class.forName("oracle.jdbc.driver.OracleDriver");
//Class.forName("com.mysql.jdbc.Driver");
//Establishing the db connection
con=DriverManager.getConnection(url,userName,password);
//Preparing the Prepared Statement object
ps=con.prepareStatement(EMP_SEARCH_DETAILS);
//set the value into query param
ps.setInt(1, eno);
//execute the sql query
rs=ps.executeQuery();
//process the result set object
if(rs.next()) {
pw.println("<h1>EMPLOYEE DETAILS</h1>");
pw.println("<h1>Employee ID:"+rs.getInt(1)+"</h1>");
pw.println("<h1>Employee Name:"+rs.getString(2)+"</h1>");
pw.println("<h1>Employee Job:"+rs.getString(3)+"</h1>");
pw.println("<h1>Employee Sal:"+rs.getDouble(4)+"</h1>");
pw.println("<h1>Employee Dept NO:"+rs.getInt(5)+"</h1>");
}
}catch (SQLException se) {
se.printStackTrace();
pw.println("<h1 style='color:red;'>Internal Database problem</h1>");
}
catch (ClassNotFoundException cnf) {
cnf.printStackTrace();
pw.println("<h1 style='color:red;'>Internal problem</h1>");
}
catch (Exception e) {
e.printStackTrace();
pw.println("<h1 style='color:red;'>Internal problem</h1>");
}finally {
rs.close();
ps.close();
con.close();
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
doGet(req, res);
}
}
, а исключение на консоли выглядит следующим образом
Exception::java.security.AccessControlException: access denied
Каким может быть сценарий ios, когда можно получить это исключение? И как мне это решить?