import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; public class CreateStatementExample { public static void main(String[] args) { try { // Creating a connection to the database Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", "root", ""); // Creating a statement object Statement stmt = conn.createStatement(); // Executing a query String sql = "SELECT * FROM customers WHERE age > 18;"; stmt.executeQuery(sql); // Closing the statement and connection stmt.close(); conn.close(); } catch(Exception ex) { ex.printStackTrace(); } } }In this example, we first establish a connection to a MySQL database. Then we create a Statement object using the createStatement method. We execute a SELECT query using the executeQuery method on the Statement object. Finally, we close the statement and connection objects. The createStatement method belongs to the java.sql package library, which is a part of the Java Database Connectivity (JDBC) API. This package provides classes and interfaces for connecting to a database, executing SQL statements, and retrieving results.