here is my code
public void transSpanish()
{
if (comboSpanish.getSelectedItem().equals(spanWrd))
System.out.println("hi im: " +spanWrd);//test for now
{
jTextArea1.setText(""+ spanWrd +" translates to the english ");//just to see in text area for now
try
{
//connection to DB
Connection con = DriverManager.getConnection(url, user, password);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT English from translator WHERE Spanish="+spanWrd);
while (rs.next())
{
int col = 0;
String English = rs.getString("English");
//pulls from DB and translates word from spanish to english
jTextArea1.setText("" + English);
}//end while
stmt.close();
con.close();
}//end try
catch (Exception e)
{
System.out.println(e);
}//end catch
}//end if spanWrd
my table is called translator
my Primarykey is wordID
the other fields are (wordID, Category, English, Spanish, Categoría)
this function works....fine...all i want to do in the first function is take the spanish word from the choice box
and compare it to the table then in the textArea show the english word.... ???? any comment :)
im getting sometype of error...missing parameter...
//this function works
public void viewWords()
{
//Set string array to the column headers
String columnheaders[] = {"Category", "English", "Spanish", "Categoría"};
int row = 2; //start at row two on table
tblWords.setFont(new Font("Dialog", 0, 10));
tblWords.setEnabled(false);
// show column headers
for (int i=0; i<columnheaders.length; i++)
tblWords.setValueAt(columnheaders[i], 0, i);
try
{
Connection con = DriverManager.getConnection(url, user, password);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT Category, English, Spanish, Categoría FROM translator");
while (rs.next())
{
//Get information from database to variables
int col = 0;
String Category = rs.getString("Category");
String English = rs.getString("English");
String Spanish = rs.getString("Spanish");
String Categoría = rs.getString("Categoría");
tblWords.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
//Print information out in a row
tblWords.setValueAt(Category, row, col);
col++;
tblWords.setValueAt(English, row, col);
col++;
tblWords.setValueAt(Spanish, row, col);
col++;
tblWords.setValueAt(Categoría, row, col);
row++;
}//while
stmt.close();
con.close();
}//try
catch (Exception e)
{
System.out.println(e);
}//catch
}//viewWords()
Ghost