| 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 |
[!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.