Skip to content

Commit

Permalink
[SQLLINE-80] In HOWTO, describe how to run SQLLine in IntelliJ IDEA's…
Browse files Browse the repository at this point in the history
… console on Windows (slankka)

Edited for spelling/grammar (Julian Hyde).
  • Loading branch information
slankka authored and julianhyde committed Jul 25, 2018
1 parent f162096 commit 5a8f8bf
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,52 @@ mvn release:clean
git status
git reset --hard HEAD
```

## Running SQLLine inside IntelliJ IDEA's console on Windows

On Windows 10, SQLLine ignores user input in IDEA's Run/Debug Console.
When you type the command then hint `<Enter>`, SQLLine does not
respond. (This is logged as
[<a href="https://github.com/julianhyde/sqlline/issues/80">SQLLINE-80</a>].)

The problem is caused by the compatibility between Jline2 and IDEA.
IDEA's console is a non-standard console and is poorly supported by
Jline. Jline uses a JNI call to get Console or Terminal information.

Even Jline3 does not work much better. While SQLLine still uses
JLine2, the best workaround is to use a launcher that sets terminal
options, as follows:

```java
public class LaunchSqlline {
public static void main(String[] args) {
try {
List<String> stringList = new LinkedList<>();
stringList.add("-d org.apache.phoenix.queryserver.client.Driver");
stringList.add("-u 'jdbc:phoenix:thin:url=http://localhost:8765'");
stringList.add("-n none");
stringList.add("-p none");
stringList.add("--incremental=false");
stringList.add("--isolation=TRANSACTION_READ_COMMITTED");
/*
// Read [SQLLINE-80] to see why maxWidth must be set
stringList.add("--maxWidth=160");
stringList.add("--maxHeight=2000");
stringList.add("--color=true");
*/

// Add this line, the Console should respond to your command
jline.TerminalFactory.registerFlavor(
jline.TerminalFactory.Flavor.WINDOWS,
UnsupportedTerminal.class);

String join = StringUtils.join(stringList, " ");
String[] argsGiven = join.split(" ");

SqlLine.main(argsGiven);
} catch (IOException e) {
e.printStackTrace();
}
}
}
```

0 comments on commit 5a8f8bf

Please sign in to comment.