--- title: "setReadOnly Method (SQLServerConnection) | Microsoft Docs" ms.custom: "" ms.date: "01/19/2017" ms.prod: sql ms.prod_service: connectivity ms.reviewer: "" ms.technology: connectivity ms.topic: conceptual apiname: - "SQLServerConnection.setReadOnly" apilocation: - "sqljdbc.jar" apitype: "Assembly" ms.assetid: bd11fd50-f092-43a0-a6bc-c63e70cff8da author: David-Engel ms.author: v-daenge --- # setReadOnly Method (SQLServerConnection) [!INCLUDE[Driver_JDBC_Download](../../../includes/driver_jdbc_download.md)] Puts this [SQLServerConnection](../../../connect/jdbc/reference/sqlserverconnection-class.md) object in read-only mode as a hint to the JDBC driver to enable database optimizations. > [!NOTE] > This method is not supported by the [!INCLUDE[jdbcNoVersion](../../../includes/jdbcnoversion_md.md)]. ## Syntax ``` public void setReadOnly(boolean readOnly) ``` #### Parameters *readOnly* **true** if the connection is to be read-only. Otherwise, **false**. ## Exceptions [SQLServerException](../../../connect/jdbc/reference/sqlserverexception-class.md) ## Remarks This setReadOnly method is specified by the setReadOnly method in the java.sql.Connection interface. ## See Also [SQLServerConnection Members](../../../connect/jdbc/reference/sqlserverconnection-members.md) [SQLServerConnection Class](../../../connect/jdbc/reference/sqlserverconnection-class.md)