Found 9326 Articles for Object Oriented Programming

What are advantages of using JSP?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

3K+ Views

Following table lists out the other advantages of using JSP over other technologies −vs. Active Server Pages (ASP)The advantages of JSP are twofold. First, the dynamic part is written in Java, not Visual Basic or other MS specific language, so it is more powerful and easier to use. Second, it is portable to other operating systems and non-Microsoft Web servers.vs. Pure ServletsIt is more convenient to write (and to modify!) regular HTML than to have plenty of println statements that generate the HTML.vs. Server-Side Includes (SSI)SSI is really only intended for simple inclusions, not for "real" programs that use form ... Read More

What is Java Server Pages, JSP? Why JSP is preferred over CGI?

Samual Sam
Updated on 30-Jul-2019 22:30:25

973 Views

JavaServer Pages (JSP) is a technology for developing Webpages that support dynamic content. This helps developers insert java code in HTML pages by making use of special JSP tags, most of which start with .A JavaServer Pages component is a type of Java servlet that is designed to fulfill the role of a user interface for a Java web application. Web developers write JSPs as text files that combine HTML or XHTML code, XML elements, and embedded JSP actions and commands.Using JSP, you can collect input from users through Webpage forms, present records from a database or another source, and ... Read More

How to write a JDBC program to extract data from multiple databases?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

970 Views

To connect with a data base, you need toRegister the DriverSelect the required database register the Driver class of the particular database using the registerDriver() method of the DriverManager class or, the forName() method of the class named Class.DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get connectionCreate a connection object by passing the URL of the database, username and password of a user in the database (in string format) as parameters to the getConnection() method of the DriverManager class.Connection mysqlCon = DriverManager.getConnection(mysqlUrl, "root", "password");And, to extract data you need to execute the select query as:ResultSet rs = stmt.executeQuery("Select * from Employee");To print the contents of the ... Read More

How to write a JDBC application which connects to multiple databases simultaneously?

Nancy Den
Updated on 30-Jul-2019 22:30:25

5K+ Views

To connect with a database, you need toRegister the Driver: Select the required database, register the Driver class of the particular database using the registerDriver() method of the DriverManager class or, the forName() method of the class named Class.DriverManager.registerDriver(new com.mysql.jdbc.Driver());Get connection: Create a connection object by passing the URL of the database, username and password (of a user in the database) in string format, as parameters to the getConnection() method of the DriverManager class.Connection mysqlCon = DriverManager.getConnection(mysqlUrl, "root", "password");To connect to multiple databases in a single JDBC program you need to connect to the two (or more) databases simultaneously using ... Read More

What are bind variables? How to execute a query with bind variables using JDBC?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

5K+ Views

A bind variable is an SQL statement with a temporary variable as place holders which are later replaced with appropriate values. For example, if you have a table named employee in the database created as shown below:+---------+--------+----------------+ | Name | Salary | Location | +---------+--------+----------------+ | Amit | 30000 | Hyderabad | | Kalyan | 40000 | Vishakhapatnam | | Renuka | 50000 | Delhi | | Archana | ... Read More

What are the types of statements in JDBC?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

10K+ Views

There are three types of statements in JDBC namely, Statement, Prepared Statement, Callable statement.StatementThe Statement interface represents the static SQL statement. It helps you to create a general purpose SQL statements using Java.Creating a statementYou can create an object of this interface using the createStatement() method of the Connection interface.Create a statement by invoking the createStatement() method as shown below.Statement stmt = null; try { stmt = conn.createStatement( ); . . . } catch (SQLException e) { . . . } finally { . . . }Executing the ... Read More

What are the main classes and interfaces of JDBC?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

11K+ Views

JDBC API is available in two packages java.sql, core API and javax.sql JDBC optional packages. Following are the important classes and interfaces of JDBC.Class/interfaceDescriptionDriverManagerThis class manages the JDBC drivers. You need to register your drivers to this.It provides methods such as registerDriver() and getConnection().DriverThis interface is the Base interface for every driver class i.e. If you want to create a JDBC Driver of your own you need to implement this interface. If you load a Driver class (implementation of this interface), it will create an instance of itself and register with the driver manager.StatementThis interface represents a static SQL statement. ... Read More

How to establish connection with JDBC?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

1K+ Views

To connect with a database, you need to follow the steps given below:Step1: Register the driver: To develop a basic JDBC application, first of all, you need to register the driver with the DriverManager.You can register a driver in two ways, one is using registerDriver() method of the DriverManager class and, using forName() method of the class named Class.The registerDriver() method accepts an object of the Driver class, it registers the specified Driver with the DriverManager.Driver myDriver = new com.mysql.jdbc.Driver(); DriverManager.registerDriver(myDriver);The forName() method loads the specified class into the memory and thus it automatically gets registered.Class.forName("com.mysql.jdbc.Driver");Step2: Get Connection: Get the ... Read More

What is type4 driver of JDBC what are the advantages and disadvantages of it?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

843 Views

The Type 4 driver is the pure Java driver. It implements database specific protocol to communicate with the database directly. This driver is provided by the vender itself, this is flexible driver compared to other drivers.Advantages of type4 driverFollowing are the advantages of the type4 driver.It is purely developed in Java and it is the platform independent driver.Unlike type-1 driver there is no need to install OCI, ODBC functions.While using this driver there is no need for middleware server.Disadvantages of type4 driverFollowing are the disadvantages of type4 driver.Type-4 driver internally uses database specific proprietary protocol and it is database dependent. ... Read More

What is type3 driver of JDBC what are the advantages and disadvantages of it?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

646 Views

In a Type 3 driver, a three-tier approach is used to access databases. The JDBC clients use standard network sockets to communicate with a middleware application server. The socket information is then translated by the middleware application server into the call format required by the DBMS, and forwarded to the database server.This kind of driver is extremely flexible, since it requires no code installed on the client, a single driver can actually provide access to multiple databases. You can think of the application server as a JDBC "proxy, " meaning that it makes calls for the client application. As a ... Read More

Advertisements