public class Addh001 {
public void add(String h00101,String h00102,int h00103,String h00104,int h00105,int h00106 ,DataSource ds) throws SQLException {
// TODO Auto-generated method stub Connection conn=null;
try{
conn=ds.getConnection();

System.out.println(h00101+h00102+h00103+h00104+h00105+h00106);
System.out.println("ok");
PreparedStatement ps=conn.prepareStatement("insert into h001 values(?,?,?,?,?,?)");
 ps.setString(1, h00101);

 
 ps.setString(2, h00102);
 ps.setInt(3,h00103);
 ps.setString(4, h00104);
 ps.setInt(5,h00105);
 ps.setInt(6, h00106);  ps.executeUpdate();
 conn.commit();
System.out.println(h00101+h00102+h00103+h00104+h00105+h00106);
conn.commit(); }finally

if(conn!=null)
conn.close(); }
}
}

解决方案 »

  1.   

    具体的错误是什么,贴上来,看看是 oracle 的错误,还是 java  的错误。
      

  2.   

    java.lang.NullPointerException.     
      

  3.   

    你这是 java错误啊,调试下哪一步报的错
      

  4.   

    借楼,我的也是执行到executeBatch就卡住,楼主问题解决了吗,求各位大佬帮我看看
    public static void updateCategory_ID() {
    try {
    int j=0;
    con = DBConn.getConnection();
    String sql = "select * from O8100_SPXX_201907_4 where category_id like '%//%' ";
    String sql1 = "update O8100_SPXX_201907_4  set category_id =? where goods_id =?";
    ps = con.prepareStatement(sql);
    rs = ps.executeQuery();
    con.setAutoCommit(false);
    ps = con.prepareStatement(sql1);
    while (rs.next()) {
    String category_id = rs.getString("category_id");
    String[] array = category_id.split(" ");
    String category_id1 = "";
    for (int i = 0; i < array.length; i++) {
    Matcher matcher = Pattern.compile("(com/|item/)(\\d+)").matcher(array[i]);
    while (matcher.find()) {
    category_id1 = matcher.group(2) + " " + category_id1;
    }
    }
    ps.setString(1, category_id1);
    ps.setString(2, rs.getString("goods_id"));
    ps.addBatch();
    System.out.println(category_id1);
    j++;
    if(j%1000==0)
    {
    con.setAutoCommit(false);
    ps.executeBatch();
    con.commit();
    ps.clearBatch();
    }
    }
    ps.executeBatch();
    con.commit();// 执行完后,手动提交事务
    con.setAutoCommit(true);
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } finally {
    try {
    if (con != null) {
    con.close();
    } if (rs != null) {
    rs.close();
    }
    if (ps != null) {
    ps.close();
    } } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    }