Taebu / prq

prq.co.kr
MIT License
1 stars 0 forks source link

java class decompiler #28

Closed Taebu closed 8 years ago

Taebu commented 8 years ago

/usr/local/apache-tomcat-6.0.43/webapps/callerid/WEB-INF/classes/com/wind/korea/callerid CalleridReceiveServlet.java JdbcUtils.java

Taebu commented 8 years ago

CalleridReceiveServlet.java

package com.wind.korea.callerid;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CalleridReceiveServlet extends HttpServlet
{
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
  {
    doPost(req, resp);
  }

  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException
  {
    String port = req.getParameter("port");
    String callerid = req.getParameter("callerid");
    String userid = req.getParameter("userid");

    if ((port != null) && (callerid != null) && (userid != null)) {
      List list = new ArrayList();
      list.add(userid);
      list.add(port);
      list.add(callerid);
      try
      {
        JdbcUtils.updateByPreparedStatement("insert into cdr(date,UserID,port,callerid) values(now(),?,?,?)", list);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }
}

decompile 한 결과

JdbcUtils.java

package com.wind.korea.callerid;

import java.io.PrintStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

public class JdbcUtils
{
  private static final String USERNAME = "root";
  private static final String PASSWORD = "hanna0987";
  private static final String DRIVER = "com.mysql.jdbc.Driver";
  private static final String URL = "jdbc:mysql://localhost:3306/callerid";

  static
  {
    try
    {
      Class.forName("com.mysql.jdbc.Driver");
      System.out.println("데이터베이스 연결에 성공!");
    }
    catch (Exception localException)
    {
    }
  }

  private static Connection getConnection()
  {
    try
    {
      return DriverManager.getConnection("jdbc:mysql://localhost:3306/callerid", "root", "hanna0987");
    }
    catch (SQLException e)
    {
      e.printStackTrace();
    }
    return null;
  }

  public static boolean updateByPreparedStatement(String sql, List<Object> params)
    throws SQLException
  {
    boolean flag = false;
    int result = -1;
    Connection connection = getConnection();
    PreparedStatement pstmt = connection.prepareStatement(sql);
    int index = 1;
    if ((params != null) && (!params.isEmpty())) {
      for (int i = 0; i < params.size(); i++) {
        pstmt.setObject(index++, params.get(i));
      }
    }
    result = pstmt.executeUpdate();
    pstmt.close();
    connection.close();
    flag = result > 0;
    return flag;
  }
}