传参数无返回值的 java 调oracle的存储过程.(向数据库表中插入数据)

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

public class JavaOracleProcedure1 {
    
    JavaOracleProcedure1()
throws Exception
    
{
        String driver
="oracle.jdbc.driver.OracleDriver";
        String url
="jdbc:oracle:thin:@localhost:1521:WJDB";
        String strUser
="wjorac";
        String strPwd
="wangjun";
        Connection conn
=null;
        CallableStatement cstm
=null;

        
try{
        Class.forName(driver);
        conn
=DriverManager.getConnection(url,strUser,strPwd);
        cstm
=conn.prepareCall("{call TEST_PRO(?,?)}");
        
//
        
//
        cstm.setString(1,"200");
        cstm.setString(
2,"wangjun2");
        cstm.executeUpdate();
        }

        
catch(Exception ex)
        
{
            ex.printStackTrace();
        }

        
finally
        
{
            
if(cstm!=null)
                cstm.close();
            
if(conn!=null)
                conn.close();
        }

    }

    
public static void main(String args[])throws Exception
    
{
            
new JavaOracleProcedure1();
    }

}

posted @ 2008-04-10 13:52  wj-conquer  阅读(655)  评论(0编辑  收藏  举报