Join date: May 14, 2022

Ensiklopedi Akhir Zaman Pdf 582 [Latest-2022]




The Java Database Connectivity (JDBC) API allows applications to use relational databases to access, create, update, and delete data from an SQL Server. This article discusses the JDBC classes that you need to connect to SQL Server and the methods you need to use in the JDBC program. The methods you will use to perform updates and inserts, delete, and fetch records from the database are described. The problems of the JDBC API are also discussed. Accessing the JDBC API in your web application is discussed in section 4.4. At times, you may need to perform all operations in a database in the form of transactions. Transactions are covered in section 5.2. What Is JDBC? An application programming interface (API) is a system or set of routines that a software developer can use to interact with a database. The Java Database Connectivity (JDBC) API defines a standard API for accessing SQL Server. Create an Open Connection An open connection to a database is established using the Connection object. This object provides methods to execute SQL statements. The create method opens a connection to the server. This method takes no arguments. The result of the method is a connection object that is used to retrieve records from the database. The connection returned by the create method is automatically closed when you use the ResultSet object to retrieve records from the database. For example, if you execute the following statements, the connection is automatically closed after the Statement class generates the results of the command to the database. Connection connection = DriverManager.getConnection(); // Create an open connection Statement statement = connection.createStatement(); // Use the connection object ResultSet resultSet = statement.executeQuery("SELECT * FROM people"); // Retrieve records Connecting to an SQL Server There are three types of connection to the database: connection pooling, application pooling, and none. Connection pooling refers to the configuration of a pool of connections with the SQL Server. Application pooling refers to the configuration of the program that runs the Java program that connects to the database. None means you do not use a connection. Creating a Connection Pool The JDBC API uses connection pooling by default. If your application does not use a connection, you can use the Connection object returned by the create method to create a connection pool. This can be useful if the Java program must connect to multiple SQL Servers. For example, the following statement connects to an SQL Server and closes the connection




Ensiklopedi Akhir Zaman Pdf 582 [Latest-2022]
More actions