import java.sql.SQLException;
import java.util.Locale;
+import net.jaekl.squelch.db.DbDriver;
+
public class Select extends Query {
@Override
}
@Override
- public int exec(Connection conn, PrintWriter pw, String line) throws IOException, SQLException
+ public int exec(DbDriver driver, Connection conn, PrintWriter pw, String line) throws IOException, SQLException
{
int rowCount = 0;
- try (PreparedStatement ps = conn.prepareStatement(line))
+ // If there's a ';' on the end of this line, remove it.
+ String trimmed = line.trim();
+ if (trimmed.endsWith(";")) {
+ trimmed = trimmed.substring(0, trimmed.length() - 1);
+ }
+
+ try (PreparedStatement ps = conn.prepareStatement(trimmed))
{
try (ResultSet rs = ps.executeQuery())
{
private int printFormatted(PrintWriter pw, ResultSet rs) throws IOException, SQLException
{
TabularResultSet trs = new TabularResultSet(rs);
- int rowCount = trs.printTable(pw);
+ // TODO: StringTable i18n
+ int rowCount = trs.printTable(pw, "No rows returned.");
pw.flush();
return rowCount;