为了账号安全,请及时绑定邮箱和手机立即绑定

怎么又错误啊

package jdbc;


import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;


public class Liu {

private static final String URL="jdbc:mysql://127.0.0.1:3306/imooc";

private static final String USER="root";

private static final String PASSWORD="123456";

public static void main(String[] args) throws Exception {

// TODO Auto-generated method stub

    Class.forName("com.mysql.jdbc.Driver");

   Connection conn=DriverManager.getConnection(URL, USER, PASSWORD);

    Statement stmt=conn.createStatement();

   ResultSet rs= stmt.executeQuery("select user_name,age form imooc_goddess");

   while(rs.next()) {

   System.out.println(rs.getString("user_name")+","+rs.getInt("age"));

   }

}


}


正在回答

1 回答

错误显示

Exception in thread "main" com.mysql.jdbc.exceptions.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 'imooc_goddess' at line 1

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)

at com.mysql.jdbc.Connection.execSQL(Connection.java:3277)

at com.mysql.jdbc.Connection.execSQL(Connection.java:3206)

at com.mysql.jdbc.Statement.executeQuery(Statement.java:1232)

at jdbc.Liu.main(Liu.java:17)


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

怎么又错误啊

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信