Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page import="java.sql.*" %>
- <%@ page import="java.io.*" %>
- <%@ include file="blocks/header.jsp" %>
- <%
- Boolean bd_ai_create, bd_jbpm4_create;
- String ai_login, jbpm4_login, ai_pas, jbpm4_pas, db_pas, db_login;
- String db_host = request.getParameter("db_host");
- String one_pas[] = request.getParameterValues("one_pas");
- db_pas = request.getParameter("db_pas");
- db_login = request.getParameter("db_login");
- //Если используется единый логин и пароль к бд
- if (one_pas != null && one_pas[0].equals("one_pas")){
- ai_login = db_login;
- jbpm4_login = db_login;
- ai_pas = db_pas;
- jbpm4_pas = db_pas;
- session.setAttribute( "g_one_pas", "true" );
- } else {
- //Если для каждой схемы используется свой пароль
- ai_login = request.getParameter("ai_login");
- jbpm4_login = request.getParameter("jbpm4_login");
- ai_pas = request.getParameter("ai_pas");
- jbpm4_pas = request.getParameter("jbpm4_pas");
- session.setAttribute( "g_one_pas", "false" );
- }
- String ai_name = request.getParameter("ai_name");
- String jbpm4_name = request.getParameter("jbpm4_name");
- String[] bd_ai_create_yn;
- session.removeAttribute("g_db_host");
- session.removeAttribute("g_ai_login");
- session.removeAttribute("g_jbpm4_login");
- session.removeAttribute("g_ai_pas");
- session.removeAttribute("g_jbpm4_pas");
- session.removeAttribute("g_ai_name");
- session.removeAttribute("g_jbpm4_name");
- session.setAttribute( "g_db_host", db_host );
- session.setAttribute( "g_ai_login", ai_login );
- session.setAttribute( "g_jbpm4_login", jbpm4_login );
- session.setAttribute( "g_ai_pas", ai_pas );
- session.setAttribute( "g_jbpm4_pas", jbpm4_pas );
- session.setAttribute( "g_ai_name", ai_name );
- session.setAttribute( "g_jbpm4_name", jbpm4_name );
- String ai_connect_status = "Всё ок", jbpm4_connect_status = "Всё ок", check;
- int ai_connect_code = 9999, jbpm4_connect_code = 9999;
- check = "" + request.getParameter("check");
- //Проверяем доступ к базе данных (если, пользователь не пропускает проверку)
- if (!check.equals("skip")){
- //Доступ к ai
- try {
- String connectionURL = "jdbc:mysql://" + db_host + ":3306/" + ai_name;
- Connection connection = null;
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- connection = DriverManager.getConnection(connectionURL, ai_login, ai_pas);
- if(!connection.isClosed()){
- ai_connect_status = "success";
- }
- connection.close();
- } catch(SQLException ex){
- ai_connect_status = ex.getMessage();
- ai_connect_code = ex.getErrorCode();
- session.setAttribute("ai_connect_status", ai_connect_status);
- session.setAttribute("ai_connect_code", ai_connect_code);
- }
- //Доступ к jbpm4
- try {
- String connectionURL = "jdbc:mysql://" + db_host + ":3306/" + jbpm4_name;
- Connection connection = null;
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- connection = DriverManager.getConnection(connectionURL, jbpm4_login, jbpm4_pas);
- if(!connection.isClosed())
- jbpm4_connect_status = "success";
- connection.close();
- } catch(SQLException ex){
- jbpm4_connect_status = ex.getMessage();
- jbpm4_connect_code = ex.getErrorCode();
- session.setAttribute("jbpm4_connect_status", jbpm4_connect_status);
- session.setAttribute("jbpm4_connect_code", jbpm4_connect_code);
- }
- }
- if (ai_connect_status != "success" || jbpm4_connect_status != "success") {
- if (ai_connect_code != 1049 && jbpm4_connect_code != 1049){
- response.sendRedirect("error.jsp?step=db_settings.jsp");
- }
- }
- %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement