samedi 29 septembre 2018

I just used "SELECT * FORM table1" but" java.sql.SQLSyntaxErrorException" [on hold]

this is my code.

    String username1 = request.getParameter("username");
    String password1 = request.getParameter("password");
    Class.forName("com.mysql.jdbc.Driver");
    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/testjdbc?serverTimezone=UTC&characterEncoding=utf-8","root","123456");
    Statement stmt = connection.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT * FORM table1");
    while(rs.next()){
        out.println(rs.getString("username"));
        out.println(rs.getString("password"));
    }

when I run it, I get some error,I don't know why. I just used "SELECT * FORM table1",I'm sure table1 exists.

java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FORM table1' at line 1
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
    at com.mysql.cj.jdbc.StatementImpl.executeQuery(StatementImpl.java:1218)
    at org.apache.jsp.dologin_jsp._jspService(dologin_jsp.java:136)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at...




Aucun commentaire:

Enregistrer un commentaire