Getting Rows from a Database Table - Java JDBC

Java examples for JDBC:Table

Description

Getting Rows from a Database Table

Demo Code

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Main {
  public static void m() {
    Connection connection = null;
    try {/*from w  w w .  j  a  v a  2s . co  m*/
      // Create a result set containing all data from my_table
      Statement stmt = connection.createStatement();
      ResultSet rs = stmt.executeQuery("SELECT * FROM my_table");
    } catch (SQLException e) {
      // Could not connect to the database
    }
  }
}

Related Tutorials