I am using the .executeScalar()
method from the sql2o .jar file. I am getting this exception when using an Employee POJO, when I use .executeScalar(Employee.class)
I am getting:
org.sql2o.converters.ConverterException: No converter registered for class: com.mack.sales.employees.Employee
I cannot find anything to help resolve this issue, any help is appreciated.
Converters are what sql2o uses to convert from database values to Java values. For instance, if one of your properties in your pojo is an integer, sql2o uses its integer converter to convert from any compatible database datatype (int, number, etc) to integer.
The executeScalar method will fetch only one value (first column and first row) from the database and convert it to a Java value. It is meant to be used with single value queries. For instance a select count(*) from table.
To fetch multiple columns and map their values to a pojo, you can use the executeAndFetchFirst()
method.