哪位大神帮下,测试连接数据库,这些错误是什么意思?
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'imooc.imooc' doesn't exist
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.Util.getInstance(Util.java:387)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:942)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3966)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3902)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2526)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2673)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2545)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2503)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1369)
at com.iooc.db.DBUtil.main(DBUtil.java:22)
代码如下package com.iooc.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class DBUtil {
private static final String URL="jdbc:mysql://127.0.0.1:3306/imooc";
private static final String USER="root";
private static final String PASSWORD="admin";
public static void main(String[] args) throws Exception {
//1、加载驱动程序
Class.forName("com.mysql.jdbc.Driver");
//2、获得数据库的连接
Connection conn= DriverManager.getConnection(URL, USER, PASSWORD);
//3、通过数据库的连接操作数据库,实现增删改查
Statement stmt= conn.createStatement();
ResultSet rs= stmt.executeQuery("Select user_name,age from imooc_goddess");
while(rs.next()){
System.out.println(rs.getString("user_name"+","+rs.getInt("age")));
}
}
}