Thursday, January 28, 2010

JDBC Java Program Using JDBC TYPE 3 Driver

A Sample Java Program Using JDBC TYPE 3 Driver. This driver is called as Network Protocol Pure Java Driver. This driver would only be the option when DB vendor supplied Type II & IV drivers are not available.

Software: www.idssoftware.com


Server:


a) Install IDSServer software


b) d:\IDSServer\IDSS.exe


(The above said .exe runs as system startup service. IDSS.exe is a server socket program which runs on port number 12.)


c) Notice one more dir called


d:\IDSServer\classes>


jdk11drv.jar, jdk13drv.jar, jdk14drv.jar


Client:
a) Client must demand server to download jdk14drv.jar file into client system and the same must be updated in CLASSPATH

[Note: Software installation is not required]


PATH: (only server)


d:\IDSServer


CLASSPATH (server & client)


d:\IDSServer\classes\jdk14drv.jar


Arch:


Driver: ids.driver.IDSDriver


URL: jdbc:ids://abc:12/conn?dsn='oracleSysDSN'


Procedure creation


c:> sqlplus scott/tiger


SQL> cle scr


sql> create or replace procedure emp_sal_proc(eno IN number, sal1 OUT number) IS

BEGIN

SELECT sal INTO sal1 FROM emp WHERE empno=eno;

END;


// Java
Program

// ProcExecTest.java


import java.sql.*;
public class ProcExecTest

{

public static void main(String rags[]) throws Exception

{

Class.forName("ids.driver.IDSDriver");

Connection
con=DriverManager.getConnection
("jdbc:ids://abc:12/conn?dsn
='oracleSysDSN'", "scott", "tiger");
CallableStatement cstmt=con.prepareCall("{call emp_sal_proc(?,?)}");

cstmt.setInt(1, Integer.parseInt(rags[0]));

cstmt.registerOutParameter(2, Types.DOUBLE);

cstmt.execute();

System.out.println(cstmt.getDouble(2));

cstmt.close();

con.close();

}// main()

}// class

0 comments:

Blog Widget by LinkWithin

JS-Kit Comments

  © Blogger template Newspaper III by Ourblogtemplates.com 2008

Back to TOP