TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

JDBC

JDBC ResultSet Interface

Overview

In this post, we will learn about JDBC ResultSet Interface in JDBC API. A Result Set represents a table of data, which is usually generated by executing an SQL statement that selects the data from the database. For example, SQL SELECT query.

Import ResultSet

We can import the ResultSet in the Java application code from the java.sql package.

import java.sql.ResultSet;

Code Example

The following code retrieves the rows from the dept database table.

String sqlQuery = “SELECT * FROM dept”;

connection = DriverManager.getConnection(url, username, password);

Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(sqlQuery);

while (rs.next()) {
int deptno = rs.getInt(1);
String dname= rs.getString(2);
String loc = rs.getString(3);
System.out.println(String.format(“%-20s”, deptno)
+ String.format(“%-20s”, dname)
+ String.format(“%-20s”, loc));
}

Related Posts

tnsnames File Oracle TestingDocs

JDBC /

Connect to Oracle Database using JDBC Thin Driver

Display Oracle Database Table JDBC

JDBC /

Display data from Oracle Database table using JDBC

JDBC API TestingDocs

JDBC /

JDBC API Components

Configure Build Path Eclipse

JDBC /

Configure JDBC Driver in Java Project

JDBC DriverManager Class

JDBC /

JDBC DriverManager Class

‹ Configure JDBC Driver in Java Project› JDBC API Components

Recent Posts

  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Print Triangle Pattern Flowchart
  • RAPTOR Editions
  • Flowgorithm Conditional Breakpoint Statement
  • Flowgorithm Read Numbers from File Example
  • Search Text File Flowchart Example
  • Flowgorithm Turtle Graphics Symbols
  • Draw Circle using Flowgorithm Turtle

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version