为什么我在oracle的数据库的表里面插入一条信息会不成功呢?代码如下:
importjava.sql.Connection;importjava.sql.DriverManager;//importjava.sql.ResultSet;imp...
import java.sql.Connection;
import java.sql.DriverManager;
//import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class TestDML {
public static void main(String args[]) {
//ResultSet rs = null;
Statement stmt = null;
Connection conn = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.179.169:1521:orcl", "scott", "tiger");
stmt = conn.createStatement();
String sql = "insert into dept2 (deptid,deptname,deptadd,deptphone,email) values ('10','YHS','guangzhou','632','375338553@qq.com')";
stmt.executeUpdate(sql);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if(stmt != null) {
stmt.close();
stmt = null;
}
if(conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
提示的错误信息是:
java.sql.SQLException: ORA-00942: 表或视图不存在
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:330)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:287)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:742)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:206)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:945) 展开
import java.sql.DriverManager;
//import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class TestDML {
public static void main(String args[]) {
//ResultSet rs = null;
Statement stmt = null;
Connection conn = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.179.169:1521:orcl", "scott", "tiger");
stmt = conn.createStatement();
String sql = "insert into dept2 (deptid,deptname,deptadd,deptphone,email) values ('10','YHS','guangzhou','632','375338553@qq.com')";
stmt.executeUpdate(sql);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if(stmt != null) {
stmt.close();
stmt = null;
}
if(conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
提示的错误信息是:
java.sql.SQLException: ORA-00942: 表或视图不存在
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:330)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:287)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:742)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:206)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:945) 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询