반응형



import java.sql.*;
import java.util.*;

public class RunProc {

	public static void main(String arg[]) {
		
		Common.loadDrover();
		Connection con = null;

		CallableStatement cstmt = null;

		try {
			con = DriverManager.getConnection(
					"jdbc::oracle:thin:@127.0.0.1:1521:orcl", "사용자아이디",
					"사용자 패스워드");
			System.out.print("저장할 메시지: ");
			Scanner sc = new Scanner(System.in);
			String msg = sc.nextLine();
			sc.close();

			cstmt = con.prepareCall("{call myproc(?)}");
			cstmt.setString(1, msg);
			cstmt.executeQuery();
		} catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			try {
				if (cstmt != null)
					cstmt.close();
				if (con != null)
					con.close();

			}

			catch (Exception e) {
			}
		}

	}

}



+ Recent posts