0
点赞
收藏
分享

微信扫一扫

ORA-00942: 表或视图不存在

在pl/sql中使用oracle的system用户创建了一张表emp,因为使用dba身份登录的,用java代码能获取连接

public static Connection getConnection() throws Exception{
Connection conn = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@127.0.0.1:1521:orcl",
"System", "ognl");
} catch (Exception e) {
e.printStackTrace();
throw e;
}
return conn;

这是获取的连接

oracle.jdbc.driver.T4CConnection@deb6432

但是去操作表时,就发生

java.sql.SQLSyntaxErrorException: ORA-00942: 表或视图不存在

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:861)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1145)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1267)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3493)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
at dao.EmployeeDAO.findAll(EmployeeDAO.java:109)
at test.EmployeeDAOTest.testFindAll(EmployeeDAOTest.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)

网络上有很多的原因是表名写错了,或者因为加了引号而引起的,但我这里可以排除这个原因


捣鼓了半天怀疑是权限的问题,我就用SCOTT用户创建表,然后


Java代码中也用SCOTT用户操作表,就没有问题,至于前面的权限问题,有时间在研究研究


举报

相关推荐

0 条评论