0
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/hibernate","root","root");
String query1= "select * from registration where email= ? and password= ? ";
PreparedStatement ps = con.prepareStatement(query1);
ps.setString(1,email);
ps.setString(2,password);
ResultSet rs1= ps.executeQuery(query1);
rs1.next();
String s= rs1.getString("type");
out.println(s);
我收到以下錯誤 -爲什麼我得到錯誤語法錯誤?
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 '? and password= ?' at line 1
然後如何執行查詢,如果我不指定查詢1裏面ps.executeQuery()像ps.executeQuery(query1) – user3871262 2014-09-01 08:17:51
謝謝我得到它和它的工作 – user3871262 2014-09-01 08:27:26