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(); }
}
}
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(); }
}
}
解决方案 »
- group by分组查询00979报错问题
- 关于多对多转化成一对一的问题.
- 请教一个sql语句
- 怎么把数据导出成xml格式!!高分!!!!!
- 有什么专业工具可以对oracle 8i数据库进行辅助分析、并可以清楚了解到表表之间对应关系?
- 在oracle下,刪除一表裡的內容時,在沒有寫觸發器的情況另一表的內容也刪除了,為什麼?
- 在oracle里插入一条记录,如何知道该记录的ID值?
- 推荐学习pro*c的好书?最好说明书名,出版社,作者
- 改表空间数据文件名之后出错
- 有哪位大虾在linux redhat 7.2下成功安装了oracle 9i或者8.1.7?
- Oracle 12c 数据泵导出错误
- 哪位大大有ocp考试的vce文件,谢谢了
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();
}
}
}