HomeНаука и техникаRelated VideosMore From: tech fort

6 Advanced java |JDBC Type1 Driver|Connection is interface/class | Connection object adv java

69 ratings | 600 views
#Advanced java tutorial : #adv java Procedure to create a DSN for Microsoft ODBC Driver for Oracle: 1)Keep the Oracle s/w ready (Installed on your computer/system) 2) Make sure that values in the path environment variable are placed as shown below: my computer-----right clique----- properties----- select advanced tab-------environment Variable-----user/system variables Add Variable Name:PATH Value:D:\Program Files\Java\jdk1.6.0_11\bin;D:\oracle\product\10.2.0\db_1\BIN;. Note: Dont create same path in user & system variable otherwise it will create problem. 3)Create DSN Optimal while working with local/standalone oracle & mandatory ----dsn string should be passed while working with centralized oracle(Sever) Drivers Information: Sun MS has given 5 approached/methodologies/architectures to make vendor companies to develop JDBC drivers based on jdbc specification & guideline, rules. Type 1 Type 2 Type 3 Type 4 Type 5(latest) -The sun Supplied built in JDBC Driver of JDK is Type 1 mechanism based JDBC Driver. - Type 1 JDBC Driver internally uses native code(the code is used in java but written in C/C++) to interact with ODBC Driver. - Type 1 Driver can interact with multiple ODBC drivers of different database s.w. -To use JDBC Driver in our appln it must be registers with DriverManager service. -Driver manager is basic service available in every java application having the capability to manage JDBC Driver. -We can access DriverManager service in our appln by using java.sql.DriverManager class. - To register the jdbc driver the object of jdbc driver class must be placed/aviailable in DriverManager service as shown below: //create the object of jdbc driver class(Type 1) sun.jdbc.odbc.JdbcOdbcDriver obj = new sun.jdbc.odbc.JdbcOdbcDriver(); //register jdbc driver with DriverManager service DriverManager.registerDriver(obj); #Standard stpes to develop JDBC code in Java appln: 1)Register JDBC Driver with DriverManger service. 2)Establish the connection between java application & database sotware. 3)Create JDBC Statement object. 4)Send & execute SQL queries in DB s/w. 5) Gather the result from database s/w & process them in java appln. 6)Close the resourecse(like connecion, stmt) Note ; 1 Registering JDBC Driver is nothing but keeping JDCB driver class object in driver manager service. 2) Establishing tje connection i nothing but creating comuunnicatoin channel/bridge/stream between java appln & database s/w. 3) JDBC Statement object is nothing but java appln & database s/w. It carries input(Sql queries) from java appln to databse s/w & it also carries/bring output(given by database s/w) back to java appln. @. How to develop java application/program without using main(-) method? # Minimum s/w setup required for Type 1 JDBC Application development:- 1)JDK any(UPTo JDK 1.6) 2)Oracle any version (Oracle 10g) 3)DSN Create for Microsoft ODBC Driver (for like oradsn). PROTOTYPE OF registerDriver(-), getConnection(-,-,-) method:- public static void registerDriver(Driver driver) throws SQL Exception *1 *2 public static Connection getConnection(String url,String dbuser,String dbpwd) throws SQLException *1 -- indicate regsterDriver(-) mthod must be called having implemantation class object of java.sql.Driver(Interface). *2 --indicates values(generally Connection) of getConneciton(-,-,-) method retuns the implementation class object of java.sql.Connection (Interface). WHat is protocole:- Protocol is the set of rules followed by two parties to commnitcate with each other. Two Types of protocol 1)Application level protocol: Contains rules to get interaction between two s/ws or two s/w specification. ex jdbc:odbc http rmi Etc 2)Network Level Protocol: Contains rules to perform interaction b/w two physical computers ex: TCP/IP DriverManager service uses jdbc:odbc as application level protocol to interact with dataabase s/w using Type 1JDBC driver & ODBC Driver. I Q. When DriverManager.getConnection("jdbc:odbc:oradsn","scott","boss"); is called? - Based on given jdbc url the type 1 driver will be activated. - Based on dsn name (like "oradsn") word of jdbc url the type 1 driver will becomes ready to Microsoft ODBC Driver for Oracle. -DriverManager service takes the support of Type 1 jdbc driver & odbc driver to establish the connection with Oracle database s.w. In this process the jdbc:odbc protocol will be utilized. -It returns JDBC connection object representing the connectivity with Oracle DB S.w from java applln
Html code for embedding videos on your blog
Text Comments (0)

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.