各位,我在Oracle数据库里面删除一条数据,之后在Java里面查询这条数据,结果显示还是存在这条数据,这是为什么?
这是jdbc连接的代码:
public class DbTools {
Connection connection;
public Connection getConn() {
try{
//load the driver
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@localhost:1521:orcl";
String userName = "system";
String password = "123";
//get the connection object
connection = DriverManager.getConnection(url, userName, password);
}catch (ClassNotFoundException e){
e.printStackTrace();
}catch (SQLException e){
e.printStackTrace();
}
return connection;
}
}
表名:useinfo
1.usename
2.password
我在数据库里面先删除“22222”这条数据:
![删除数据](https://img-ask.csdn.net/upload/201710/31/1509395121_210391.jpg)
我再在java里面查询这条数据:
public static void searchJDBC(String name){
String sql = String.format("select * from useinfo where username='%s'", name);
DbTools dbTools = new DbTools();
Connection connection = dbTools.getConn();
try{
//create the statement object
Statement statement=connection.createStatement();
ResultSet resultSet = statement.executeQuery(sql);
while(resultSet.next()) {
System.out.println(resultSet.getString("username")+ " "+ resultSet.getString("password"));
}
}catch (SQLException e){
e.printStackTrace();
}
}
结果显示这条数据还是存在的 请问是什么原因?