Home > database >  One to executeUpdate will be abnormal??????
One to executeUpdate will be abnormal??????

Time:09-15

Public class Addh001 {
Public void the add (String h00101, String h00102, int h00103, String h00104, int h00105, int h00106, DataSource ds) throws SQLException {
//TODO Auto - generated method stub

The Connection conn=null;


Try {
Conn=ds. GetConnection ();

System. Out. Println (h00101 + h00102 + h00103 + h00104 + h00105 + h00106);
System. The 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.com MIT ();
System. Out. Println (h00101 + h00102 + h00103 + h00104 + h00105 + h00106);
Conn.com MIT ();

} the finally
{
If (conn!=null)
conn.close();

}
}
}

CodePudding user response:

What is the specific error and post, see oracle was wrong, or Java errors,

CodePudding user response:

Java. Lang. NullPointerException.

CodePudding user response:

You this is a Java error, debugging under which step in the wrong

CodePudding user response:

By building, I also perform to executeBatch is stuck, the building Lord problem solved, please, help me see
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. Get String (" category_id ");
String [] array=category_id. Split (" ");
String category_id1="";
for (int i=0; i The Matcher Matcher=Pattern.com running (" (com/| item/) (\ \ d +) "). The Matcher (array [I]);
While (the matcher. The find ()) {
Category_id1=the matcher. Group (2) + "" + category_id1;
}
}
Ps. SetString (1, category_id1);
Ps. SetString (2, rs. Get string (" goods_id "));
Ps. The addBatch ();
System. The out. Println (category_id1);
j++;
If (j %==0 1000)
{
Con. SetAutoCommit (false);
Ps. ExecuteBatch ();
Con.com MIT ();
Ps. ClearBatch ();
}
}
Ps. ExecuteBatch ();
Con.com MIT ();//after the execution, manual commit the transaction
Con. SetAutoCommit (true);
} the catch (Exception e) {
//TODO Auto - generated the catch block,
e.printStackTrace();
} the finally {
Try {
If (con!=null) {
Con. The close ();
}

if (rs !=null) {
rs.close();
}
If (ps!=null) {
ps.close();
}

} the catch (SQLException e) {
//TODO Auto - generated the catch block,
e.printStackTrace();
}
}
}
  • Related