import java.io.IOException;
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MysqlReverseFunctionServlet extends HttpServlet
{
	public void doGet(HttpServletRequest req, HttpServletResponse res)
		throws IOException, ServletException
	{
		res.setContentType("text/html");
		PrintWriter pw = res.getWriter();
		String driver = "com.mysql.jdbc.Driver";
		String url = "jdbc:mysql://192.168.10.13/data";
		String uid = "root";
		String psw = "root";
		String sql = "SELECT REVERSE('DEVMANUALS.COM');";
		Connection con;
		PreparedStatement ps;
		ResultSet rs;
		try
		{
			Class.forName(driver);
			con = DriverManager.getConnection(url,uid,psw);
			ps = con.prepareStatement(sql);
			rs = ps.executeQuery();
			while(rs.next())
			{
				String rev = rs.getString(1);
				pw.println(rev);
			}
		}
		catch(SQLException sx)
		{
			pw.println(sx);
		}
		catch(ClassNotFoundException cx)
		{
			pw.println(cx);
		}
	}
}