搞定车商代码缓存!
This commit is contained in:
parent
a4d1e51da8
commit
6572379132
@ -50,6 +50,7 @@ void initCarDealerMap()
|
|||||||
string errorMessage = "ocilib初始化失败!";
|
string errorMessage = "ocilib初始化失败!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//连接
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pConnection = OCI_ConnectionCreate( tnsName.c_str(),
|
pConnection = OCI_ConnectionCreate( tnsName.c_str(),
|
||||||
@ -60,8 +61,45 @@ void initCarDealerMap()
|
|||||||
catch ( runtime_error & error )
|
catch ( runtime_error & error )
|
||||||
{
|
{
|
||||||
//连接数据库失败
|
//连接数据库失败
|
||||||
|
string errorMessage = "连接数据库失败!";
|
||||||
|
|
||||||
|
errorMessage.append(error.what());
|
||||||
|
|
||||||
OCI_Cleanup();
|
OCI_Cleanup();
|
||||||
|
|
||||||
|
throw runtime_error(errorMessage.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pStatement = OCI_StatementCreate( pConnection );
|
||||||
|
|
||||||
|
OCI_ExecuteStmt( pStatement, sql.c_str() );
|
||||||
|
|
||||||
|
pResult = OCI_GetResultset( pStatement );
|
||||||
|
pCarDealerMap = new unordered_map<string, CarDealer>;
|
||||||
|
|
||||||
|
while ( OCI_FetchNext( pResult ) == true )
|
||||||
|
{
|
||||||
|
string carDealerCodeIndex = OCI_GetString( pResult, 1 );
|
||||||
|
QString carDealerCode = QString::fromLocal8Bit( OCI_GetString( pResult, 1 ) );
|
||||||
|
QString carDealerName = QString::fromLocal8Bit( OCI_GetString( pResult, 2 ) );
|
||||||
|
|
||||||
|
CarDealer dealer( carDealerCode, carDealerName );
|
||||||
|
|
||||||
|
pCarDealerMap->insert( pair<string, CarDealer>( carDealerCodeIndex, dealer ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( runtime_error & error )
|
||||||
|
{
|
||||||
|
string errorMessage = "执行查询失败!";
|
||||||
|
|
||||||
|
errorMessage.append(error.what());
|
||||||
|
|
||||||
|
OCI_Cleanup();
|
||||||
|
|
||||||
|
throw runtime_error(errorMessage.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
OCI_Cleanup();
|
OCI_Cleanup();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user