Mercurial > hg > monetdb-java
view src/main/java/nl/cwi/monetdb/mcl/embedded/EmbeddedReader.java @ 61:f1de7262d8d9 embedded
First changes to the JDBC driver.
author | Pedro Ferreira <pedro.ferreira@monetdbsolutions.com> |
---|---|
date | Thu, 24 Nov 2016 18:12:44 +0100 (2016-11-24) |
parents | |
children |
line wrap: on
line source
package nl.cwi.monetdb.mcl.embedded; import nl.cwi.monetdb.mcl.connection.AbstractBufferedReader; import java.io.*; /** * Created by ferreira on 11/24/16. */ public class EmbeddedReader extends AbstractBufferedReader { protected EmbeddedReader() { super(null); } @Override public String readLine() throws IOException { String res = this.readLineInternal(); setLineType(res); if (lineType == ERROR && !res.matches("^![0-9A-Z]{5}!.+")) res = "!22000!" + res.substring(1); return res; } @Override public synchronized String waitForPrompt() throws IOException { try { this.wait(); } catch (InterruptedException e) { throw new IOException(e); } String res = this.readLine(); if (res == null) { throw new IOException("Connection to server lost!"); } if (lineType == ERROR) { return "\n" + res.substring(1); } return res.trim(); } private native String readLineInternal(); }