In my project I did some code to search employee name from database table and load it into jcombobox.

**Table Name**: `employee`

**column names**: `empid(Primarykey), emp_name, position`

Usually I code my searching query like this.

```
public void EmployeeName1(JComboBox comboName) {
    Vector v = new Vector();
    try {
        ResultSet rs = db.getData("select emp_name from employee");
        v.add("--SELECT--");
        while (rs.next()) {
            v.add(rs.getString("emp_name"));
            comboName.setModel(new DefaultComboBoxModel(v));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

```

It is working very well.

But now I did some diffrent on this code.

```
public void EmployeeName1(JComboBox comboName) {
    Vector v = new Vector();
    try {
        String columnName = "emp_name";
        String tableName = "employee";
        ResultSet rs = db.getData("select columnName from tableName");
        v.add("--SELECT--");
        while (rs.next()) {
            v.add(rs.getString(columnName));
            comboName.setModel(new DefaultComboBoxModel(v));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

```

But when I'm running this code I'm having this error.

```
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'textile.tablename' doesn't exist

```

This is my db class code:

```
package Model;

//import static Model.JDBC.con;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;

public class JDBC {

    static String driver = "com.mysql.jdbc.Driver";
    static String url = "jdbc:mysql://localhost/textile";
    static Connection con;
    static boolean b;

    public static void setCon() {
        try {
            Class.forName(driver);
            con = DriverManager.getConnection(url, "root", "access456");
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex);
        }
    }

    public static Connection getCon() throws Exception {
        if (con == null) {
            setCon();
        }
        return con;
    }

    public static boolean putData(String sql) {
        try {
            PreparedStatement state = getCon().prepareStatement(sql);
            state.executeUpdate();
            b = true;
        } catch (Exception ex) {
            b = false;
            JOptionPane.showMessageDialog(null, ex);
        }
        return b;
    }

    public static ResultSet getData(String sql) throws Exception {
        Statement state = JDBC.getCon().createStatement();
        ResultSet rset = state.executeQuery(sql);
        return rset;
    }
}

```