use of com.teradata.jaqy.Session in project jaqy by Teradata.
the class CloseCommand method execute.
@Override
public void execute(String[] args, boolean silent, JaqyInterpreter interpreter) {
SessionUtils.checkOpen(interpreter);
Session session = interpreter.getSession();
session.close(interpreter, false);
// interpreter.println ("Session " + session.getId () + " is now closed.");
}
use of com.teradata.jaqy.Session in project jaqy by Teradata.
the class ExecCommand method execute.
@Override
public void execute(String[] args, boolean silent, JaqyInterpreter interpreter) throws Exception {
if (args.length == 0) {
interpreter.setParseAction(this, null);
} else {
CommandLine cmdLine = getCommandLine(args);
args = cmdLine.getArgs();
String charset = null;
for (Option option : cmdLine.getOptions()) {
if ("c".equals(option.getOpt())) {
charset = option.getValue();
}
}
if (args.length > 0) {
Path file = interpreter.getPath(args[0]);
if (!file.exists()) {
interpreter.error("file not found: " + args[0]);
}
SessionUtils.checkOpen(interpreter);
Reader reader = FileUtils.getReader(file.getInputStream(), charset);
String sql = StringUtils.getStringFromReader(reader);
Session session = interpreter.getSession();
session.executeQuery(sql, interpreter, interpreter.getRepeatCount());
// now reset things
interpreter.setRepeatCount(1);
interpreter.setLimit(0);
} else {
interpreter.setParseAction(this, null);
}
}
}
use of com.teradata.jaqy.Session in project jaqy by Teradata.
the class ExecCommand method parse.
@Override
public void parse(String action, Object value, boolean silent, Globals globals, JaqyInterpreter interpreter) throws Exception {
SessionUtils.checkOpen(interpreter);
if (!silent) {
Display display = interpreter.getDisplay();
display.echo(interpreter, action, false);
}
Session session = interpreter.getSession();
session.executeQuery(action, interpreter, 1);
}
use of com.teradata.jaqy.Session in project jaqy by Teradata.
the class ImportSchemaCommand method execute.
@Override
public void execute(String[] args, boolean silent, JaqyInterpreter interpreter) throws Exception {
JaqyImporter<?> importer = interpreter.getImporter();
if (importer == null) {
interpreter.error("There is no current import.");
}
SchemaInfo schemaInfo = importer.getSchema();
if (schemaInfo == null) {
interpreter.error("Current import schema is not available.");
}
boolean displaySQL = false;
CommandLine cmdLine = getCommandLine(args);
for (Option option : cmdLine.getOptions()) {
switch(option.getOpt().charAt(0)) {
case 's':
{
displaySQL = true;
break;
}
}
}
SessionUtils.checkOpen(interpreter);
Session session = interpreter.getSession();
JaqyHelper helper = session.getConnection().getHelper();
if (displaySQL) {
String sql = SchemaUtils.getTableSchema(helper, schemaInfo, "TABLENAME", false);
interpreter.println(sql);
} else {
JaqyResultSet rs = SchemaUtils.getSchemaResultSet(helper, schemaInfo, false, interpreter);
interpreter.print(rs);
rs.close();
}
}
Aggregations