이 페이지에서

QSqlError Class

QSqlError 클래스는 SQL 데이터베이스 오류 정보를 제공합니다. 더 보기...

헤더: #include <QSqlError>
CMake: find_package(Qt6 REQUIRED COMPONENTS Sql)
target_link_libraries(mytarget PRIVATE Qt6::Sql)
qmake: QT += sql

공개 유형

enum ErrorType { NoError, ConnectionError, StatementError, TransactionError, UnknownError }

공개 함수

QSqlError(const QString &driverText = QString(), const QString &databaseText = QString(), QSqlError::ErrorType type = NoError, const QString &nativeErrorCode = QString())
QSqlError(const QSqlError &other)
QSqlError(QSqlError &&other)
~QSqlError()
QString databaseText() const
QString driverText() const
bool isValid() const
QString nativeErrorCode() const
void swap(QSqlError &other)
QString text() const
QSqlError::ErrorType type() const
bool operator!=(const QSqlError &other) const
QSqlError &operator=(QSqlError &&other)
QSqlError &operator=(const QSqlError &other)
bool operator==(const QSqlError &other) const

상세 설명

QSqlError 객체는 driverText() 및 databaseText() 메시지(또는 둘을 연결한 text()), 그리고 nativeErrorCode() 및 type()을 포함하여 데이터베이스별 오류 데이터를 제공할 수 있습니다.

QSqlDatabase::lastError() 및 QSqlQuery::lastError()도 참조하십시오 .

멤버 유형 문서

enum QSqlError::ErrorType

이 열거형 유형은 오류가 발생한 상황을 설명합니다(예: 연결 오류, 문 오류 등).

상수값설명
QSqlError::NoError0오류가 발생하지 않았습니다.
QSqlError::ConnectionError1연결 오류.
QSqlError::StatementError2SQL 문 구문 오류.
QSqlError::TransactionError3트랜잭션 실패 오류.
QSqlError::UnknownError4알 수 없는 오류.

멤버 함수 문서

QSqlError::QSqlError(const QString &driverText = QString(), const QString &databaseText = QString(), QSqlError::ErrorType type = NoError, const QString &nativeErrorCode = QString())

driverText 라는 드라이버 오류 메시지, databaseText 라는 데이터베이스별 오류 메시지, type 라는 유형 및 nativeErrorCode 라는 네이티브 오류 코드를 포함하는 오류 객체를 생성합니다.

QSqlError::QSqlError(const QSqlError &other)

other 의 복사본을 생성합니다.

[constexpr noexcept default] QSqlError::QSqlError(QSqlError &&other)

QSqlError 인스턴스를 이동 생성하여, 해당 인스턴스가 other 가 가리키던 것과 동일한 객체를 가리키게 합니다.

참고: 이동된객체 other 는 부분적으로 형성된 상태가 되며, 이 상태에서는 소멸과 새 값 할당만이 유효한 연산입니다.

[noexcept] QSqlError::~QSqlError()

객체를 삭제하고 할당된 리소스를 모두 해제합니다.

QString QSqlError::databaseText() const

데이터베이스에서 보고한 오류 메시지를 반환합니다. 여기에는 데이터베이스 고유의 설명이 포함될 수 있으며, 빈 문자열일 수도 있습니다.

driverText() 및 text()도 참조하십시오 .

QString QSqlError::driverText() const

드라이버가 보고한 오류 메시지를 반환합니다. 여기에는 데이터베이스별 설명이 포함될 수 있습니다. 또한 빈 문자열일 수도 있습니다.

databaseText() 및 text()도 참조하십시오 .

bool QSqlError::isValid() const

오류가 설정되어 있으면 ` true `을 반환하고, 그렇지 않으면 `false`를 반환합니다.

예시:

QSqlQueryModel model;
model.setQuery("select * from myTable");
if (model.lastError().isValid())
    qDebug() << model.lastError();

type()도 참조하십시오 .

QString QSqlError::nativeErrorCode() const

데이터베이스별(네이티브) 오류 코드를 반환하며, 오류 코드를 확인할 수 없는 경우에는 빈 문자열을 반환합니다.

참고: 일부 드라이버(DB2 또는 ODBC 등)는 하나 이상의 오류 코드를 반환할 수 있습니다. 이 경우 오류 코드 사이에는 ' ; '가 구분자로 사용됩니다.

[noexcept] void QSqlError::swap(QSqlError &other)

이 오류를 other 로 교체합니다. 이 작업은 매우 빠르며 절대 실패하지 않습니다.

QString QSqlError::text() const

이 함수는 ` databaseText()`와 ` driverText()`의 결과를 하나의 문자열로 연결하여 반환하는 편의 함수입니다.

driverText() 및 databaseText()도 참조하십시오 .

QSqlError::ErrorType QSqlError::type() const

오류 유형을 반환하며, 유형을 확인할 수 없는 경우에는 -1을 반환합니다.

bool QSqlError::operator!=(const QSqlError &other) const

other 오류의 type() 및 nativeErrorCode()를 이 오류와 비교하고, 서로 같지 않을 경우 true 를 반환합니다.

[noexcept] QSqlError &QSqlError::operator=(QSqlError &&other)

other 를 이 QSqlError 인스턴스에 이동 할당합니다.

참고: 이동된객체 other 는 부분적으로 형성된 상태가 되며, 이 상태에서는 소멸과 새 값 할당만이 유효한 연산입니다.

QSqlError &QSqlError::operator=(const QSqlError &other)

other 오류의 값을 이 오류에 할당합니다.

bool QSqlError::operator==(const QSqlError &other) const

other 오류의 type() 및 nativeErrorCode()를 이 오류와 비교하여, 결과가 true 와 일치하는지 확인합니다.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.