简体   繁体   English

无法从Oracle 11g数据库读取表

[英]Cannot read table from oracle 11g database

This is my code: 这是我的代码:

import java.sql.*;

public class NewClass {
    public static void main(String[] args) {
       try{  
           Class.forName("oracle.jdbc.driver.OracleDriver");  
           Connection con=DriverManager.getConnection("jdbc:oracle:thin:@//127.0.0.1:1521/xe","system","apnair9902");  
           java.sql.Statement stmt = con.createStatement();  
           ResultSet rs=stmt.executeQuery("select * from INV_MASTER");  
           while(rs.next())  
                System.out.println(rs.getString(1)+"  "+rs.getString(2)+"  "+rs.getString(3));  
           con.close();
      }catch(Exception e){ System.out.println(e);}  
   }
}
`

I get the error: 我得到错误:

java.sql.SQLException: ORA-00942: table or view does not exist

I have created and edited the table from browser but the program cannot find the database. 我已经从浏览器创建并编辑了表格,但是程序找不到数据库。

You are selecting from a table that doesn't exist, or you are connecting to the database in a manner which leaves the table not accessible to this connection. 您正在从一个不存在的表中进行选择,或者正在以一种使该连接无法访问该表的方式连接到数据库。

To create the table, connect to the database (in whatever manner you may) and run the appropriate SQL command. 要创建表,请连接数据库(以任何方式)并运行适当的SQL命令。 It resembles something like 它类似于

CREATE TABLE INV_MASTER (
  ... column stuff ...
  ) ... optional stuff ...;

Of course, you need to know what to fill in for the columns and options appropriate to your particular needs. 当然,您需要知道要填写哪些列和选项以适合您的特定需求。

If the table is already supposed to be there, then you are connecting to the wrong database, using the wrong user (which will put you in the wrong SCHEMA, or database "area") or someone who's handling the setup of the database hasn't setup the database yet. 如果该表应该已经存在,那么您正在使用错误的用户(这将使您进入错误的SCHEMA或数据库“区域”)连接到错误的数据库,或者正在处理数据库设置的人员没有尚未建立数据库。

Also, double check that the table you want really is called INV_MASTER and that you don't need to prefix it with a schema. 另外,再次检查您真正想要的表是否称为INV_MASTER,并且不需要在其前面加上模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM