Решил сделать через временую таблицу - занесло.
Кому интересно, вот код:
int i=0;
String query = "create table new as select * from {table} order by {field}";
String request = "drop table {table};";
String query1 = "create table {table} as select * from new order by {field}";
String query2 = "drop table new;";
query = query.replace("{table}", txtTbl.getText());
query1 = query1.replace("{table}", txtTbl.getText());
request = request.replace("{table}", txtTbl.getText());
switch (jCBoxSort.getSelectedIndex()){
case 0://типу
query = query.replace("{field}", "id_vtype");
query1 = query1.replace("{field}", "id_vtype");
System.out.println("Type");
break;
case 1://по назві
query = query.replace("{field}", "nazva");
query1 = query1.replace("{field}", "nazva");
System.out.println("Nazva");
break;
case 2://по жанру
query = query.replace("{field}", "id_genre");
query1 = query1.replace("{field}", "id_genre");
System.out.println("genre");
break;
case 3://по автору
query = query.replace("{field}", "id_author");
query1 = query1.replace("{field}", "id_author");
System.out.println("author");
break;
case 4://по описанию
query = query.replace("{field}", "description");
query1 = query1.replace("{field}", "description");
System.out.println("description");
break;
case 5://по id
query = query.replace("{field}", "id");
query1 = query1.replace("{field}", "id");
System.out.println("id");
break;
default:
query = query.replace("{field}", "");
query1 = query1.replace("{field}", "");
}
if (jRadioBtnZrost.isSelected()){//по зростанню
query += " ASC;";
query1 += " ASC;";
}
else{//по спаданню
query += " DESC;";
query1 += " DESC;";
}
System.out.println(query);
System.out.println(request);
System.out.println(query1);
System.out.println(query2);
query(query);
query(request);
query(query1);
query(query2);