我只得到结果??????当我使用 java Servlet 在 Eclipse 中读取数据库时
结果是英语
福特福克斯电动汽车达到 100 英里/加仑以上 福特开始生产福克斯电动汽车,声称它将在效率方面超越电动汽车竞争对手,同时它的目标是丰田普锐斯,其 C-Max 混合动力和插电式混合动力预计将在下半年推出明年的。
工作正常。
但作为阿拉伯语不起作用'D39H/J)//这应该是阿拉伯语'DEEDC)
package website;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Home extends HttpServlet {
private static final long serialVersionUID = 8443024680664769771L;
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
res.setCharacterEncoding("utf-8");
PrintWriter out = res.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>info");
out.println("</title>");
out.println("</head>");
out.println("<body>");
out.println("<center>");
out.println("<table>");
out.println("<tr>");
out.println("<td>");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:website");
Statement stat = con.createStatement();
//ResultSet rs=stat.executeQuery("select * from res where word='"+search+"' or web='"+search+"'");
ResultSet rs = stat.executeQuery("select * from news");
String hyper = null;
while (rs.next()) {
String header = rs.getString("headline");
hyper = rs.getString("link");
String info = rs.getString("info");
out.println("<a href=" + hyper + ">" + header + "</a>");
out.println("<p>" + info + "</p>");
}
} catch (SQLException e) {
// TODO: handle exception
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
out.println("</td>");
out.println("</tr>");
out.println("</table>");
out.println("</body>");
out.println("</html>");
out.close();
}
}