How can I return two different type of columns (int , string) separately in a MySQL table? I have tried using this code but I can't figure it out. Please kindly, can you tell me what's wrong?
please notes :::i want to return keyid_col and key_col
Here is my code :::
public void retrieve_keyword () throws SQLException{
try {
ResultSet results = statement.executeQuery
("SELECT keyword_id,key_words FROM keywordlist");
try {
while ( results.next() ) {
int numColumns =
results.getMetaData().getColumnCount();
int keyid_col = results.getInt("keyword_id");
String key_col = results.getString("key_words");
if (numColumns == 2) {
System.out.println(results.getObject(numColumns));
}
for ( int i = 1 ; i <= numColumns ; i++ ) {
System.out.println( "COLUMN " + i + " = " + results.getObject(i) );
}
}
}
catch(Exception ew){
System.out.println( ew );
}
}catch(Exception ew){
System.out.println( ew );
}
}