여러 곳에서이 오류를 찾고 있었는데, 어쩌면 와일드 포인터 문제 일 수도 있지만 해결 방법을 알지 못합니다.C++ mysql sqlstring이 작동하지 않아서 0xC0000005 메모리를 읽을 수 없습니다.
질문은 C++ 커넥터가 잘 작동합니다 (열심히 노력한 후) mysql 데이터베이스에 연결하여 정보를 검색하지만 문자열 또는 sqlstring 유형을 사용할 때마다 (즉, 레코드 세트에서 정보를 가져올 수 없음) 여기
Not controlled exception at 0x5e477a8b (msvcp90d.dll) access violation when reading memory position at 0x00445355.
을 내가 사용하고 코드 : 동일한 오류
int main() {
Driver *driver;
Connection *con;
Statement *stmt;
ResultSet *res;
string fld;
char *fldName = "divisa";
int row=1, nrows=0;
char *url, *database, *usr, *pw;
url = DBHOST;
database = DATABASE;
usr = getstr("User: ", -1, 128); // char* getstr(char prompt[], char chReplace, int maxLen);
pw = new char[128];
pw = getstr("Password: ", '\0', 128);
cout << endl;
try {
driver = get_driver_instance();
con = driver->connect(url, usr, pw);
pw = new char[128];
con->setAutoCommit(0);
con->setSchema(database);
stmt = con->createStatement();
res = stmt->executeQuery("SELECT * FROM `estglob`");
while(res->next()) {
fld.assign(res->getString(fldName));
cout << fld << endl;
}
_getch();
cout << endl << "Cleaning up the resources .." << endl;
delete res;
delete stmt;
con -> close();
delete con;
}
catch (SQLException &e) {
cout << endl << "ERROR: SQLException in " << __FILE__;
cout << " (" << __FUNCTION__<< ") on line " << __LINE__ << endl;
cout << "ERROR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode() << ")";
cout << ", SQLState: " << e.getSQLState() << ")" << endl; // <== CRASH here
_getch();
return(EXIT_FAILURE);
}
catch (std::runtime_error &e)
{
cout << "ERROR: runtime_error in " << __FILE__;
cout << " (" << __FUNCTION__ << ") on line " << __LINE__ << endl;
cout << "ERROR: " << e.what() << endl;
_getch();
return(EXIT_FAILURE);
}
return(EXIT_SUCCESS);
}
이 어떤 제안이/코멘트 정말 잘 받았습니다됩니다! 그래서 여기
오류 지점에서 호출 스택!
msvcr90d.dll 방어 적이기 (서명 숯불의 *의 DST = 0x0031fa14, 서명 숯불의 *의 SRC = 0x00445355, 서명되지 않은 긴 계산 = 0x0000000f) 원격 교육 (314) 어셈블러에
msvcr90d.dll! memcpy_s (무효 * DST = 0x0031fa14, 부호 INT sizeInBytes = 0x0000000f, CONST 공극 *의 SRC = 0x00445355, 부호 INT 카운트 = 0x0000000f) 리니아 + 67 바이트 0x11을 C
msvcp90d.dll! 표준 : char_traits :: _ Copy_s (char * _First1 = 0x0031fa14, 부호없는 int _Size _size = INT _in_bytes = 0x0000000f, CONST * CHAR _First2 = 0x00445355, 부호 INT _COUNT = 0x0000000f) 리니아 582 + 0 * 16 바이트 C++
msvcp90d.dll! 표준 : _ Traits_helper :: copy_s> (* CHAR _First1 = 0x0031fa14, 부호 0x0000000f, CONST * CHAR _First2 = 0x00445355, 부호 INT _COUNT = 0x0000000f, 표준 : _ Secure_char_traits_tag __formal = {...}) 리니아 714 + 0x15 바이트 C++
msvcp90d.dll! 표준 : _ Traits_helper :: copy_s> (* CHAR _First1 = _size = 0x0000000f INT 0x0031fa14 부호를, CONST * CHAR _First2 = 0x00445355, 부호 INT _COUNT = 0x0000000f) 리니아 706 + 0x22 바이트 C++
msvcp90d.dll 표준 : basic_string, 표준 : 할당>! : : assign (const std :: basic_string, std :: a llocator> & _Right = erróneo, 부호없는 INT _Roff = 0x00000000의 서명되지 않은 INT _COUNT = 0xffffffff를) 원격 교육 1067 + 0x25로 바이트 C++
msvcp90d.dll 표준 : : basic_string, 표준 : : 할당이> : 지정 (const를 표준! : : basic_string, 표준 : 할당> = & _Right erróneo) 리니아 1,052 C++
testMySQL.exe wmain (INT는 argc = 0x00000001,은 wchar_t * argv를 = 0x00834a30) 리니아 0x8d 61 바이트 + C++
testMySQL!. exe! __ tmainCRTStartup() Línea 579 + 0x19 바이트 C
testMySQL.exe! wmainCRTStartup() Line 399 C
KERNEL32.DLL! 77,391,194()
[로스 마르코스 siguientes가 correctos O faltar없이 SE 한 cargado símbolos 파라 KERNEL32.DLL에는 산이 pueden 없음]
NTDLL.DLL! 77c7b495()
ntdll.dll! 77c7b468()
감사합니다! 해결 fld = res-> getString (fldName) .c_str(); – Miquel
당신은 어떤 컴파일러를 사용하고 있습니까? –
netbeans & cygwin을 사용하기 시작했지만 windows 통합 때문에 ms visual C++로 이동했습니다. – Miquel