一个关于jdbc的问题,求解答,谢谢!
编译没显示错误,oracle里面并没有更新数据,sql语句也没打印出来,
我用的编译工具是myeclipse 6.5,
源程序如下:
import java.sql.*;
public class TestDML2 {
public static void main(String[] args) {
Statement stmt = null;
Connection conn = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(
"jdbc:oracle:thin@118.239.51.106:1521:orcl", "scott", "tiger");
stmt = conn.createStatement();
String sql = "insert into dept2 values(99, 'GAME', 'CD')";
System.out.println(sql);
stmt.executeUpdate(sql);
} catch (
ClassNotFoundException e) {
e.getStackTrace();
} catch (
SQLException e) {
e.getStackTrace();
}finally{
try{
if(stmt != null){
stmt.close();
}if(conn != null){
conn.close();
}
}catch (SQLException e){
e.getStackTrace();
}
}
}
------解决方案--------------------conn.commit();一下看看
------解决方案--------------------蛋疼的不排版