- 论坛徽章:
- 0
|
- package mulweb.admin.login;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.postgresql.*;
- import java.sql.*;
- import javax.sql.*;
- /**
- * Servlet implementation class for Servlet: AdminLoginCheck
- *
- */
- public class AdminLoginCheck extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
- /* (non-Java-doc)
- * @see javax.servlet.http.HttpServlet#HttpServlet()
- */
- public AdminLoginCheck() {
- super();
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.Servlet#destroy()
- */
- public void destroy() {
- // TODO Auto-generated method stub
- super.destroy();
- }
-
- /* (non-Java-doc)
- * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
- */
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- // TODO Auto-generated method stub
- Connection conn = null;
- Statement stmt = null;
- ResultSet rs = null;
- response.setContentType("text/html");
- PrintWriter out = response.getWriter();
- try {
- Class.forName("org.postgresql.Driver");
- conn = DriverManager.getConnection("jdbc:postgresql://mulweb.com:5432/MulWebDb","XXXXXX","XXXXX");
- stmt = conn.createStatement();
- rs = stmt.executeQuery("SELECT * from \"test\"");
- while(rs.next()) {
- out.println(" " + rs.getString("adminUserName"));
- }
- } catch(ClassNotFoundException e) {
- out.println("Couldn\'t load database driver: " + e.getMessage());
- } catch(SQLException e){
- out.println("SQLException caught : " + e.getMessage());
- }
- finally {
- try{
- if (conn != null) conn.close();
- } catch (SQLException ignored) {}
- }
- }
- }
复制代码
执行结果:
- SQLException caught : ERROR: relation "test" does not exist
复制代码
可以%%确定test表是存在的,请问这究竟是什么原因阿? |
|