Inserting a Java object into a MySQL database
If you don't have Java 8, here are a few things you can do.


Use a string builder instead of concatenating string together. Each time you concatenate to a string, a new string is created. Using a String builder is a more efficient way of doing the same thing.

 StringBuilder sb = new StringBuilder("INSERT into authorizations (");
 sb.append("another string");
 sb.append("another string");
 String query = sb.toString();

You can use String.join to generate a comma separated string of headers

    String headers = String.join(",", authorizationHeaders);
    sb.append(headers);

I'm not sure the best way to generate the list of question marks, but this is how I normally do it.

    sb.append( ") values(");
    boolean first = true;
    for(String header: authorizationHeaders) {
        if(first){
            sb.append("?");
            first= false;
        }else{
            sb.append("?,");
        }

    }
   sb.append(")");

When setting your parameters, using i++ instead of hardcoded numbers makes code maintenance easier. If you end up needing to add one more setString(), you can add the one line of code without having adjust the rest of the indexes

    int i=1;
    ps.setString(i++,  authorization.getCompany());
    ps.setString(i++,  authorization.getPromoType());
    ps.setString(i++,  authorization.getPromoDescription());
    ps.setString(i++,  authorization.getStartDate());
    ps.setString(i++,  authorization.getEndDate());
    ps.setString(i++,  authorization.getVlMarketingNum());
    ps.setString(i++,  authorization.getMarketingNum());
    ps.setString(i++,  authorization.getStatus());
    ps.setDouble(i++,  authorization.getForecast());
    ps.setDouble(i++, authorization.getActual());