Wednesday, 11 October 2017

Introduction of Java JDBC



Before JDBC, ODBC API was the database API to relate and execute question with the database. In any case, ODBC API uses ODBC driver which is created in C lingo (i.e. organize destitute and unsecured). That is the reason Java has described its own particular API (JDBC API) that usages JDBC drivers (written in Java tongue).
 Body: What is API Programming interface (Application programming interface) is a report that contains depiction of the extensive number of components of a thing or programming. It addresses classes and interfaces that item activities can bring after to talk with each other. An API can be made for applications, libraries, working structures, et cetera .. Pushed JAVA Training in  bangalore JDBC Driver JDBC Driver is an item fragment that enables java application to interface with the database.
There are 4 sorts of JDBC drivers: 
1.            JDBC-ODBC interface driver
 2.           Native-API driver (for the most part java driver)
 3.           Network Protocol driver (totally java driver)
  4.          Thin driver (totally java driver) 
                   1) The ODBC driver ought to be presented on the client machine.
                 2) Native-API driver The Native API driver uses the client side libraries of the database.  The driver changes over JDBC procedure calls into nearby calls of the database API. It isn't made absolutely in java. Ideal position:
                performance refreshed than JDBC-ODBC associate driver. Weight:The Native driver ought to be presented on the each client machine.       The Vendor client library ought to be presented on client machine. 3) Network Protocol driver The Network Protocol driver uses middleware (application server) that converts JDBC calls clearly or roundaboutly into the trader specific database tradition. It is totally formed in java. Favored stance:     No client side library is required in light of usage server that can perform numerous errands like looking at, stack modifying, logging et cetera. Weaknesses:              
                                             Network reinforce is required on client machine.Requires database-specific coding to be done in the inside level.        Maintenance of Network Protocol driver ends up being over the top in light of the way that it requires database-specific coding to be done in the middle level. 4) Thin driver The thin driver changes over JDBC calls particularly into the trader specific database tradition. That is the reason it is known as thin driver. It is totally formed in Java vernacular. Good position:          
                                                Better execution than each and every other driver.         No writing computer programs is required at client side or server side. Injury:          Drivers depends upon the Database. 5 Steps to interface with the database in java There are 5 phases to interface any java application with the database in java using JDBC. They are according to the accompanying: Register the driver class
             Creating affiliation 
             Creating clarification
             Executing questions
             Closing affiliation
Register the driver class The forName() procedure for class is used to enroll the driver class. This technique is used to capably stack the driver class. Accentuation of forName() methodology open static void forName(String className)throws ClassNotFoundException  2) Create the affiliation challenge The getConnection() technique for DriverManager class is used to develop relationship with the database.  1) open static Connection getConnection(String url)throws SQLException  2) open static Connection getConnection(String url,String name,String mystery word) hurls SQLException  3) Create the Statement dissent The createStatement() system for Connection interface is used to make enuncia
                                The topic of decree is fit to execute request with the database. open Statement createStatement()throws SQLException  4) Execute the request The executeQuery() procedure for Statement interface is used to execute request to the database. This procedure reestablishes the topic of ResultSet that can be used to get each one of the records of a table. open ResultSet executeQuery(String sql)throws SQLException  5) Close the affiliation challenge By closing affiliation dissent enunciation and ResultSet will be closed normally. Best core java training in Bangalore

                                            The adjacent() methodology for Connection interface is used to close the affiliation. Phonetic structure of close() methodology open void close()throws SQLException Case to interface with the Oracle database in java For interfacing java application with the prophet database, you need to take after 5 phases to perform database organize. For this situation we are using Oracle10g as the database. So we need to know following information for the prophet database: 
                Driver class: The driver class for the prophet database is oracle.jdbc.driver.OracleDriver.               Connection URL: The affiliation URL for the oracle10G database is jdbc:oracle:thin:@localhost:1521:xe where jdbc is the API, prophet is the database, thin is the driver, localhost is the server name on which prophet is running, we may in like manner use IP address, 1521 is the port number and XE is the Oracle advantage name.
                         You may get every one of these information from the tnsnames.ora record.              Username: The default username for the prophet database is structure.              Password: Password is given by the customer at the period of presenting the prophet database. Two ways to deal with stack the compartment record: 1.paste the ojdbc14.jar report in jre/lib/ext envelope  2.set classpath  1) stick the ojdbc14.jar record in JRE/lib/ext coordinator: Initially, look through the ojdbc14.jar archive by then go to JRE/lib/ext envelope and paste the compartment record here.  2) set classpath: There are two ways to deal with set the classpath:
             temporary        permanent

No comments:

Post a Comment