select * 在 java 错误
select * in java error
package connectdatabase;
import java.sql.* ;
public class ConnectDatabase {
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver") ;
String url = "jdbc:mysql://localhost/student" ;
Connection db = DriverManager.getConnection(url , "root" , "") ;
Statement sqlc = db.createStatement() ;
ResultSet re = sqlc.executeQuery("SELECT * FORM studentdetail ") ;
while(re.next()) {
System.out.println("product is = "+ re.getString("Stu_name")) ;
}
}
catch(Exception e){
System.out.println(e);
}
}
}
错误代码:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的 SQL 语法有误;查看与您的 MySQL 服务器版本对应的手册,了解在第 1
行 'form studentdetail' 附近使用的正确语法
你打错了:
SELECT * FROM studentdetail
而不是
SELECT * FORM studentdetail
package connectdatabase;
import java.sql.* ;
public class ConnectDatabase {
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver") ;
String url = "jdbc:mysql://localhost/student" ;
Connection db = DriverManager.getConnection(url , "root" , "") ;
Statement sqlc = db.createStatement() ;
ResultSet re = sqlc.executeQuery("SELECT * FORM studentdetail ") ;
while(re.next()) {
System.out.println("product is = "+ re.getString("Stu_name")) ;
}
}
catch(Exception e){
System.out.println(e);
}
}
}
错误代码:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的 SQL 语法有误;查看与您的 MySQL 服务器版本对应的手册,了解在第 1
行 'form studentdetail' 附近使用的正确语法你打错了:
SELECT * FROM studentdetail
而不是
SELECT * FORM studentdetail