欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

oracle我以前的资料3.1(如何插入一条数据)

程序员文章站 2022-03-28 23:29:29
...
package com.weixun.ljn;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Test {


public static void main(String[] args) throws ClassNotFoundException, SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@192.168.18.3:1521:orcl","scott","tiger");
CallableStatement cstmt=conn.prepareCall("{call addOrder(?,?,?,?)}");
CallableStatement cstmt2=conn.prepareCall("{call addOrderDetail(?,?,?,?)}");
cstmt.setString(1,"ttt2");
cstmt.setInt(2, 555);
cstmt.setString(3,"kkk");
cstmt.setInt(4, 888);
cstmt.executeQuery();
System.out.println("插入一条订单成功!");
cstmt.close();

cstmt2.setString(1,"ttt2");
cstmt2.setInt(2, 444);
cstmt2.setInt(3, 666);
cstmt2.setInt(4, 777);
cstmt2.executeQuery();
System.out.println("插入一条相应的表单明细成功!");

cstmt2.close();
conn.close();

}

}