Batch update using statement JDBC

The JDBC statement is used to execute queries against the database. Let us study JDBC Statement by batch update example. Example: JDBCTest.java import java.sql.Connection; import java.sql.Statement; import com.w3schools.util.JDBCUtil;   /** * This class is used to batch update in DB table. * @author w3schools */ public class JDBCTest { public static void main(String args[]){ Connection … Read more

Delete record using statement JDBC

The JDBC statement is used to execute queries against the database. Let us study JDBC Statement by deletes a record example. Example: JDBCTest.java import java.sql.Connection; import java.sql.Statement; import com.w3schools.util.JDBCUtil;   /** * This class is used to delete a record from DB table. * @author w3schools */ public class JDBCTest { public static void main(String … Read more

Select record using statement JDBC

The JDBC statement is used to execute queries against the database. Let us study JDBC Statement by select records example. Example: JDBCTest.java import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import com.w3schools.util.JDBCUtil;   /** * This class is used to select a list of records from DB table. * @author w3schools */ public class JDBCTest { public … Read more

JDBC Statement updates a record example

The JDBC statement is used to execute queries against the database. Let us study JDBC Statement by update a record example. Example: JDBCTest.java import java.sql.Connection; import java.sql.Statement; import com.w3schools.util.JDBCUtil;   /** * This class is used to update a record in DB table. * @author w3schools */ public class JDBCTest { public static void main(String … Read more

JDBC Statement inserts a record example

The JDBC statement is used to execute queries against the database. Let us study JDBC Statement by insert a record example. Example: JDBCTest.java import java.sql.Connection; import java.sql.Statement; import com.w3schools.util.JDBCUtil;   /** * This class is used to insert a record in DB table. * @author w3schools */ public class JDBCTest { public static void main(String … Read more

JDBC Statement creates a table example

The JDBC statement is used to execute queries against the database. Let us study JDBC Statement by create table example. Example: JDBCTest.java import java.sql.Connection; import java.sql.Statement; import com.w3schools.util.JDBCUtil;   /** * This class is used to create a table in DB. * @author w3schools */ public class JDBCTest { public static void main(String args[]){ Connection … Read more

JDBC Statement interface

The JDBC statement is used to execute queries against the database. Statement is an interface which provides the methods to execute queries. We can get a statement object by invoking the createStatement() method of Connection interface. Syntax: Statement stmt=conn.createStatement(); Commonly used methods of Statement interface: 1. execute(String SQL): It is used to execute SQL DDL statements. … Read more

Connect to MySql database with JDBC driver

To connect with MySql database with JDBC driver follow the same basic steps discussed in previous tutorials. We have to know the following information to connect with MySql database: 1. Driver class: com.mysql.jdbc.Driver. 2. Connection URL: Syntax: “jdbc:mysql://hostname:port/dbname”,”username”, “password” Connection url for MySql database: jdbc:mysql://localhost:3306/w3schools where 3306 is the port number and w3schools is the … Read more

Connect to Oracle database with JDBC driver

To connect with oracle database with JDBC driver follow the same basic steps discussed in previous tutorials. We have to know the following information to connect with oracle database: 1. Driver class: oracle.jdbc.driver.OracleDriver. 2. Connection URL: Syntax: “jdbc:oracle:thin:@localhost:port:serviceName”,”username”, “password” Connection url for MySql database: jdbc:oracle:thin:@localhost:1521:xe where 1521 is the port number and XE is the … Read more

Steps to connect database in java

Steps to connect database in java using JDBC are given below: Load the JDBC driver. Connection. Statement. Execute statement. Close database connection.   1. Load the JDBC driver: First step is to load or register the JDBC driver for the database. Class class provides forName() method to dynamically load the driver class. Syntax: Class.forName(“driverClassName”); To … Read more