Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 1.6 KB

File metadata and controls

26 lines (18 loc) · 1.6 KB
title Using a SQL statement with no parameters
description Learn how to execute SQL statement with no parameters using the Microsoft JDBC Driver for SQL Server.
author David-Engel
ms.author davidengel
ms.date 04/20/2021
ms.service sql
ms.subservice connectivity
ms.topic conceptual

Using a SQL statement with no parameters

[!INCLUDEDriver_JDBC_Download]

To work with data in a [!INCLUDEssNoVersion] database by using a SQL statement that contains no parameters, you can use the executeQuery method of the SQLServerStatement class to return a SQLServerResultSet that will contain the requested data. First create a SQLServerStatement object by using the createStatement method of the SQLServerConnection class.

In the following example, an open connection to the [!INCLUDEssSampleDBnormal] sample database is passed in to the executeStatement function. From there, a SQL statement is constructed and run. Finally, the results are read from the result set.

:::code language="java" source="codesnippet/Java/using-an-sql-statement-w_0_1.java":::

For more information about using result sets, see Managing result sets with the JDBC driver.

See also

Using statements with SQL