Tuesday, January 10, 2012

Working with Jdbc Type5 driver

Yes,JDBC type 5 is out in the market.It has got more good features,and overcome the limitation of type4
This driver is given by vendor called DataDirect,and they have provide driver for
Oracle
MySql
SqlServer
and few more

Steps to work with Type5
----------------------------
1. goto http://www.datadirect.com/products/jdbc/index.html click on Download FreeTrial

,Register your details,and u will get the email attachment,regarding the downloads
Alternatively you can also download the same from my repository here

2.Once you have downloaded you will get  PROGRESS_DATADIRECT_CONNECT_JDBC_4.2.1.jar
Incase you have downloaded from my repository,unzip the rar,inside that u will find the above jar file

3.Extract that jar file and click on Installer.bat
Installer will be activated and this Driver will be installed in your machine.
Let us assume that it is installed in C:\Program Files\Progress\DataDirect\Connect_for_JDBC_42 folder

4.Test your connection
Goto C:\Program Files\Progress\DataDirect\Connect_for_JDBC_42\testforjdbc  and double click testforjdbc.bat

click Press Here to continue.
From the Connection menu,click Connect to DB
In the DataBase:              jdbc:datadirect:oracle://localhost:1521;databaseName=XE
         UserName:             system
         Password:              manager
 click on Connect.you will get "Connection Established" message,If its Successful

5.Writing JavaApplication using TYPE5 Driver
Test.java
----------
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
public class Test
{  
       public static void main(String[] args)throws Exception 
       {
        // Register the driver with the driver manager.
        // If using Java SE 6, you can omit this step.
        // Java SE 6 automatically registers the driver. I am Using JDK 1.6,so Commented this line
        //Class.forName("com.ddtek.jdbc.oracle.OracleDriver");         // Establish the Connection
        String url = "jdbc:datadirect:oracle://localhost:1521;ServiceName=xe";
        Connection  con = DriverManager.getConnection(url, "system", "manager");
        System.out.println("Connection is"+con);
         //We have got connection,play as u wish    // Verify the Connection
        DatabaseMetaData    metaData = con.getMetaData();
        System.out.println("Database Name: " + metaData.getDatabaseProductName());
        System.out.println("Database Version: " +metaData.getDatabaseProductVersion());    
   }
}
 
Note:Add C:\Program Files\Progress\DataDirect\Connect_for_JDBC_42\lib\oracle.jar to  your classpath
Dont want to follow all those installation step,and if you directly need oracle.jar click here
(Directly set oracle.jar in classpath and execute Test.java)


6.Compile and Execute Test.java
>javac Test.java
>java Test

o:p
Connection iscom.ddtek.jdbc.oraclebase.ddah@182f0db
Database Name: Oracle
Database Version: 10.2.0.1.0


Download Src with Oracle.jar   here


Thanks,and happy Programming



2 comments:

  1. What type-4 limitations are overcome by type-5?
    Also, how do it overcome and what are the layers for type5?

    ReplyDelete
    Replies
    1. Hi Dhruva,you can find the details here http://www.datadirect.com/index.html.
      I have stopped writing in this blog.Now a days i write nataraz.blogspot.com.Join there to stay tuned with JEE technologies

      Delete