I'm using the MySQL C++ connector and I'm trying to iterate through the resultset in the following way: The application should iterate through every column, not depending on the data type. The code should catch the data type and then proceed. The problem is that the table I'm testing with has 16 columns, but my code only runs through the first one?
try
{
driver = get_driver_instance();
con = driver->connect(connectionString, str_username, str_password);
con->setSchema(str_schema);
stmt = con->createStatement();
res = stmt->executeQuery(selectquery);
res_meta = res->getMetaData();
string datatype;
int columncount = res_meta->getColumnCount();
for (int i = 0; i < columncount; i++)
{
while (res->next())
datatype = res_meta->getColumnTypeName(i + 1);
{
if(datatype == "INT")
{
switch (res_meta->getColumnDisplaySize(i + 1))
{
case 64:
break;
case 32:
break;
default:
break;
}
}
}
}
catch(sql::SQLException &e){}