Sei sulla pagina 1di 2

Steps to follow for the compilation and executing a JDBC Program using

Type-3 Driver :
1. Create a systemdsn for type3 program . In this program I am using Oracle10g XE
edition as a Database , for this database create a dsn .
2. Creating a dsn click on start control panel Administrative Tools click on
Data Sources (ODBC) click on System DSN tab click Add button select the
Oracle in XE driver click Finish we will get Driver Configuration window
Type a Data Source Name : oradsn goto TNS Service Name Select your service
name for Example : XE,oracle,etc Click ok ok . Here the DSN is created If you
want you to check whether the DSN is working or not after selecting TNS Service Name
click Test Connection button and enter the database username and password click ok
you will get a message connection successful .The default port no for this IDS server is
12 or localhost:12 . Driver Classname is ids.sql.IDSDriver and the ConnectionUrl is
("jdbc:ids://localhost:12/conn?dsn='oradsn'&uid='scott'&pwd='tiger')
NOTE : The username and password should be entered correctly otherwise you will get
error message and in program it will not connect to the database .
3. Here we should install some third party vendor software for connecting Type-3 driver. I
am using IDS Server (This is a middleware server from a vendor (IDS software)) . This IDS
Server provides a Jdbc Type-3 Driver called IDS Driver. We can download this IDS Server
fromwww.idssoftware.com .We download a trail version of id and it is valid for 30days.
If you want to after 30 days also simply download the ids server again and re install it.
IDS driver is Type-3 driver which connects a java program with an application running in
IDS server. This application connects with a database using Type-1 driver Internally.
An application flow with IDS driver
IDS server
Java program IDS Driver Type-1 driver
4. Type the Jdbc program and save it as . java and now compile after compiling the
program set classpath =C:\IDSServer\classes; . Now execute the program. After
executing the program the Query or values will be executed or sent to Database.
Then check the database.
Application
Data
base
Sample TYPE-3 JDBC Program1 :
import java.sql.*;
class type3
{
public static void main(String[] args) throws Exception
{
Class.forName("ids.sql.IDSDriver");
Connection con = DriverManager.getConnection
("jdbc:ids://localhost:12/conn?dsn='oradsn'&uid='scott'&pwd='tiger'");
System.out.println("connection established");
Statement stmt=con.createStatement();
stmt.executeUpdate("create table type(sid number(5),sname varchar2(10))");
System.out.println("table created");
stmt.close();
con.close();
}
}
Compilation and Execution :

Potrebbero piacerti anche