|
From: SVN by r. <sv...@ca...> - 2009-03-02 08:54:05
|
Author: roy
Date: 2009-03-02 09:53:55 +0100 (Mon, 02 Mar 2009)
New Revision: 390
Modified:
src/main/java/nl/improved/sqlclient/SQLShell.java
Log:
made new tc the default
Modified: src/main/java/nl/improved/sqlclient/SQLShell.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLShell.java 2009-03-01 16:55:05 UTC (rev 389)
+++ src/main/java/nl/improved/sqlclient/SQLShell.java 2009-03-02 08:53:55 UTC (rev 390)
@@ -199,7 +199,7 @@
}
} else {
//sqlshellWindow = new SQLShellWindow();
- if (argsMap.containsKey(TABCOMPLETION) && argsMap.get(TABCOMPLETION).equals("new")) {
+ if (!argsMap.containsKey(TABCOMPLETION) || argsMap.get(TABCOMPLETION).equals("new")) {
SQLUtil.USE_V2=true;
}
if (!argsMap.containsKey(ENGINE) || argsMap.get(ENGINE).equals(ENGINE_CHARVA)) {
|
|
From: SVN by r. <sv...@ca...> - 2009-03-04 11:13:06
|
Author: roy
Date: 2009-03-04 12:12:53 +0100 (Wed, 04 Mar 2009)
New Revision: 393
Modified:
src/main/java/nl/improved/sqlclient/SQLShell.java
Log:
fix check if file can be created
Modified: src/main/java/nl/improved/sqlclient/SQLShell.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLShell.java 2009-03-04 08:08:46 UTC (rev 392)
+++ src/main/java/nl/improved/sqlclient/SQLShell.java 2009-03-04 11:12:53 UTC (rev 393)
@@ -84,7 +84,7 @@
System.err.println("Filename '"+f.getAbsolutePath()+"' cannot be written.\nAborting...");
System.exit(-1);
}
- } else if (f.createNewFile()) {
+ } else if (!f.createNewFile()) {
System.err.println("Filename '"+f.getAbsolutePath()+"' cannot be created.\nAborting...");
System.exit(-1);
}
|
|
From: SVN by r. <sv...@ca...> - 2009-03-31 19:41:11
|
Author: roy
Date: 2009-03-31 21:40:54 +0200 (Tue, 31 Mar 2009)
New Revision: 400
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
Log:
removed function calls
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-03-31 19:39:40 UTC (rev 399)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-03-31 19:40:54 UTC (rev 400)
@@ -62,7 +62,7 @@
import nl.improved.sqlclient.history.exception.CouldNotSaveHistoryException;
import nl.improved.sqlclient.util.Function;
import nl.improved.sqlclient.util.LimitedArrayList;
-import nl.improved.sqlclient.util.oracle.Functions;
+//import nl.improved.sqlclient.util.oracle.Functions;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -1020,7 +1020,7 @@
return nullToEmpty(findMatch(getTableNames(), info.getStart()));
}
if (info.getMatchType() == TabCompletionInfo.MatchType.COLUMN_NAMES) {
- if (info.getStart().length() > 0) {
+ /*if (info.getStart().length() > 0) {
try {
List<Function> functions = Functions.getFunctionMatches(getConnection(), info.getStart());
if (functions.size() > 0) {
@@ -1029,7 +1029,7 @@
} catch (SQLException ex) {
Logger.getLogger(AbstractSQLShellWindow.class.getName()).log(Level.SEVERE, null, ex);
}
- }
+ }*/
return nullToEmpty(findMatch(getColumnNames(info.getPossibleMatches()), info.getStart()));
}
if (info.getMatchType() == TabCompletionInfo.MatchType.OTHER) {
|
|
From: SVN by r. <sv...@ca...> - 2009-04-16 09:06:33
|
Author: roy
Date: 2009-04-16 11:06:27 +0200 (Thu, 16 Apr 2009)
New Revision: 402
Modified:
src/main/java/nl/improved/sqlclient/QueryExecutor.java
Log:
added support for oracle rowid select
Modified: src/main/java/nl/improved/sqlclient/QueryExecutor.java
===================================================================
--- src/main/java/nl/improved/sqlclient/QueryExecutor.java 2009-03-31 19:41:04 UTC (rev 401)
+++ src/main/java/nl/improved/sqlclient/QueryExecutor.java 2009-04-16 09:06:27 UTC (rev 402)
@@ -139,6 +139,12 @@
if (colValue == null) {
return "NULL";
} else {
+ if (colValue.getClass().getName().equals("oracle.sql.ROWID")) {
+ try {
+ java.lang.reflect.Method m = colValue.getClass().getMethod("stringValue");
+ return m.invoke(colValue).toString();
+ } catch (Throwable ex) {/* ignore .. probable no oracle jdbc in classpath*/ }
+ }
return colValue.toString();
}
}
|
|
From: SVN by r. <sv...@ca...> - 2009-04-20 19:27:38
|
Author: roy
Date: 2009-04-20 21:27:31 +0200 (Mon, 20 Apr 2009)
New Revision: 403
Modified:
src/main/java/nl/improved/sqlclient/QueryExecutor.java
Log:
fix start time
Modified: src/main/java/nl/improved/sqlclient/QueryExecutor.java
===================================================================
--- src/main/java/nl/improved/sqlclient/QueryExecutor.java 2009-04-16 09:06:27 UTC (rev 402)
+++ src/main/java/nl/improved/sqlclient/QueryExecutor.java 2009-04-20 19:27:31 UTC (rev 403)
@@ -167,6 +167,7 @@
*/
protected Iterator<CharSequence> executeQuery(CharSequence command) throws SQLException {
cancelled = false;
+ long start = System.currentTimeMillis();
ResultSet results = DBConnector.getInstance().getStatement().executeQuery(command.toString());
//StringBuffer separator = new StringBuffer();
@@ -180,7 +181,7 @@
labels.add(metadata.getColumnLabel(col));
}
- return new QueryExecutorIterator(results, labels, metadata);
+ return new QueryExecutorIterator(start, results, labels, metadata);
}
private class QueryExecutorIterator implements Iterator<CharSequence> {
@@ -189,11 +190,12 @@
private List<String> labels;
private int rowCount = 0;
private int columnCount;
- private long start = System.currentTimeMillis();
+ private long start;
private ResultSetMetaData metadata;
private boolean next = true;
- public QueryExecutorIterator(ResultSet results, List<String> labels, ResultSetMetaData metadata) throws SQLException {
+ public QueryExecutorIterator(long start, ResultSet results, List<String> labels, ResultSetMetaData metadata) throws SQLException {
+ this.start = start;
this.results = results;
this.labels = labels;
this.metadata = metadata;
|
|
From: SVN by r. <sv...@ca...> - 2009-04-20 20:12:58
|
Author: roy
Date: 2009-04-20 22:12:45 +0200 (Mon, 20 Apr 2009)
New Revision: 404
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
Log:
uncomment printstacktrace
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-04-20 19:27:31 UTC (rev 403)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-04-20 20:12:45 UTC (rev 404)
@@ -729,7 +729,7 @@
}
CharSequence newText;
if (inp.getCharacter() == '\t') {
- new Throwable().printStackTrace();
+ //new Throwable().printStackTrace();
try {
Point cursorPosition = screen.getCursorPosition();
newText = getTabCompletion(commandLines, cursorPosition);
|
|
From: SVN by r. <sv...@ca...> - 2009-04-26 12:02:14
|
Author: roy
Date: 2009-04-26 14:02:00 +0200 (Sun, 26 Apr 2009)
New Revision: 406
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
Log:
don't return null when save has an invalid option
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-04-20 20:14:57 UTC (rev 405)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-04-26 12:02:00 UTC (rev 406)
@@ -2276,7 +2276,7 @@
}
}
- return null;
+ return new SimpleCommandResult(false, "Uknown option for save. See 'help save' for options");
}
public CharSequence getCommandString() {
|
|
From: SVN by r. <sv...@ca...> - 2009-04-26 12:33:10
|
Author: roy
Date: 2009-04-26 14:33:02 +0200 (Sun, 26 Apr 2009)
New Revision: 407
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
Log:
some command history fixes
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-04-26 12:02:00 UTC (rev 406)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-04-26 12:33:02 UTC (rev 407)
@@ -348,7 +348,7 @@
}
return;
}
- StringBuffer lineBuffer = commandLines.getEditableLines().get(cursorPosition.y);
+ StringBuffer lineBuffer = getEditableCommand().getEditableLines().get(cursorPosition.y);
int previousBreak = SQLUtil.getLastBreakIndex(lineBuffer.substring(0, cursorPosition.x-1));
if (lineBuffer.charAt(previousBreak) == ' ' || lineBuffer.charAt(previousBreak) == '\t') {
previousBreak++;
@@ -366,10 +366,11 @@
public void execute() {
Point cursorPosition = screen.getCursorPosition();
if (cursorPosition.x > 0) {
- StringBuffer lineBuffer = commandLines.getEditableLines().get(cursorPosition.y);
+ StringBuffer lineBuffer = getEditableCommand().getEditableLines().get(cursorPosition.y);
lineBuffer.delete(0, cursorPosition.x);
cursorPosition.x = 0;
} else if (cursorPosition.y > 0) {
+ SQLCommand commandLines = getEditableCommand();
StringBuffer lineBuffer = commandLines.getEditableLines().get(cursorPosition.y);
if (lineBuffer.length() == 0) {
commandLines.getEditableLines().remove(cursorPosition.y);
|
|
From: SVN by r. <sv...@ca...> - 2009-04-26 13:21:04
|
Author: roy
Date: 2009-04-26 15:20:44 +0200 (Sun, 26 Apr 2009)
New Revision: 408
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
Log:
fix insert from past causing an indexoutofbounds in some cases
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-04-26 12:33:02 UTC (rev 407)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-04-26 13:20:44 UTC (rev 408)
@@ -769,11 +769,11 @@
// check if the new line is becoming too long
if (currentLine.length() > screen.MAX_LINE_LENGTH) {
// TODO search for lastspace that is not between '' ??
- int lastSpace = SQLUtil.getLastBreakIndex(currentLine.toString());//currentLine.lastIndexOf(" ");
- int lastChar = currentLine.charAt(lastSpace);
+ int lastSpace = SQLUtil.getLastBreakIndex(currentLine.toString().substring(0, screen.MAX_LINE_LENGTH-2));//currentLine.lastIndexOf(" ");
if (lastSpace == -1) {
lastSpace = currentLine.length();
}
+ int lastChar = currentLine.charAt(lastSpace);
// check if there are enough 'next' lines
// if not.. add one
if (editableLines.size()-1 == cursorPosition.y) {
|
|
From: SVN by r. <sv...@ca...> - 2009-04-26 14:08:00
|
Author: roy
Date: 2009-04-26 16:07:47 +0200 (Sun, 26 Apr 2009)
New Revision: 409
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
src/main/java/nl/improved/sqlclient/DBConnector.java
Log:
show views as well (not working currently on oracle...)
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-04-26 13:20:44 UTC (rev 408)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-04-26 14:07:47 UTC (rev 409)
@@ -886,7 +886,7 @@
protected List<String> getTableNames() {
List<String> returnValue = new ArrayList<String>();
try {
- ResultSet rs = getConnection().getMetaData().getTables(getConnection().getCatalog(), DBConnector.getInstance().getSchema(), null, new String[]{"TABLE"});
+ ResultSet rs = getConnection().getMetaData().getTables(getConnection().getCatalog(), DBConnector.getInstance().getSchema(), "%", new String[]{"%"});
while (rs.next()) {
if (!returnValue.contains(rs.getString("TABLE_NAME"))) {
returnValue.add(rs.getString("TABLE_NAME"));
Modified: src/main/java/nl/improved/sqlclient/DBConnector.java
===================================================================
--- src/main/java/nl/improved/sqlclient/DBConnector.java 2009-04-26 13:20:44 UTC (rev 408)
+++ src/main/java/nl/improved/sqlclient/DBConnector.java 2009-04-26 14:07:47 UTC (rev 409)
@@ -197,7 +197,7 @@
try {
DatabaseMetaData metaData = activeConnection.getMetaData();
ResultSet rs = metaData.getTables(activeConnection.getCatalog(), getSchema()
- , null, new String[]{"TABLE"});
+ , null, null);
while (rs.next()) {
String tableName = rs.getString("TABLE_NAME");
tableNames.put(tableName.toLowerCase(), tableName);
|
|
From: SVN by r. <sv...@ca...> - 2009-07-30 08:00:37
|
Author: roy
Date: 2009-07-30 09:33:38 +0200 (Thu, 30 Jul 2009)
New Revision: 410
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
Log:
read command fixes
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-04-26 14:07:47 UTC (rev 409)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-07-30 07:33:38 UTC (rev 410)
@@ -1823,7 +1823,12 @@
int rowCount = 0;
PrintWriter out = null;
try {
- File f = new File(toFileName(dumpFileName +".dmp"));
+ File f;
+ if (dumpFileName.toLowerCase().endsWith(".dmp")) {
+ f = new File(toFileName(dumpFileName));
+ } else {
+ f = new File(toFileName(dumpFileName +".dmp"));
+ }
fileName = f.getAbsolutePath();
if ((f.exists() && !f.canWrite()) || (!f.exists() && !f.createNewFile())) {
throw new IllegalStateException("Failed to create spool to file: '"+fileName+"'");
@@ -1854,7 +1859,7 @@
ResultSetMetaData metaData = rs.getMetaData();
for (int col = 1; col <= metaData.getColumnCount(); col++) {
atts.addAttribute("","","name","",metaData.getColumnName(col));
- if (metaData.getColumnType(col) == Types.DATE) {
+ if (metaData.getColumnType(col) == Types.DATE || metaData.getColumnType(col) == Types.TIMESTAMP) {
atts.addAttribute("","","type","","date");
atts.addAttribute("","","type_name","",metaData.getColumnTypeName(col));
hd.startElement("","","col",atts);
|
|
From: SVN by r. <sv...@ca...> - 2009-08-06 18:32:07
|
Author: roy
Date: 2009-08-06 20:31:54 +0200 (Thu, 06 Aug 2009)
New Revision: 414
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
Log:
fix tab completion for tablenames
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-08-03 07:46:11 UTC (rev 413)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-08-06 18:31:54 UTC (rev 414)
@@ -868,7 +868,7 @@
protected List<String> getTableNames() {
List<String> returnValue = new ArrayList<String>();
try {
- ResultSet rs = getConnection().getMetaData().getTables(getConnection().getCatalog(), DBConnector.getInstance().getSchema(), "%", new String[]{"%"});
+ ResultSet rs = getConnection().getMetaData().getTables(getConnection().getCatalog(), DBConnector.getInstance().getSchema(), "%", new String[]{"TABLE"});
while (rs.next()) {
if (!returnValue.contains(rs.getString("TABLE_NAME"))) {
returnValue.add(rs.getString("TABLE_NAME"));
|
|
From: SVN by r. <sv...@ca...> - 2009-09-15 13:06:49
|
Author: roy
Date: 2009-09-15 14:39:51 +0200 (Tue, 15 Sep 2009)
New Revision: 415
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
Log:
fix export for null values (byte arrays)
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-08-06 18:31:54 UTC (rev 414)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-09-15 12:39:51 UTC (rev 415)
@@ -1860,18 +1860,20 @@
byte[] bytes = new byte[bytesSize];
int read;
InputStream valueStream = rs.getBinaryStream(col);
- while ( (read = valueStream.read(bytes)) != -1) {
- if (read == 0) {
- continue;
+ if (valueStream != null) {
+ while ( (read = valueStream.read(bytes)) != -1) {
+ if (read == 0) {
+ continue;
+ }
+ if (read != bytes.length) {
+ bytes = Arrays.copyOf(bytes, read);
+ }
+ String stringValue = enc.encode(bytes) +"\n";
+ hd.characters(stringValue.toCharArray(), 0, stringValue.length());
+ if (bytes.length != bytesSize) {
+ bytes = new byte[bytesSize];
+ }
}
- if (read != bytes.length) {
- bytes = Arrays.copyOf(bytes, read);
- }
- String stringValue = enc.encode(bytes) +"\n";
- hd.characters(stringValue.toCharArray(), 0, stringValue.length());
- if (bytes.length != bytesSize) {
- bytes = new byte[bytesSize];
- }
}
} else {
atts.addAttribute("","","type","",Integer.toString(metaData.getColumnType(col)));
|
|
From: SVN by r. <sv...@ca...> - 2009-09-19 13:15:41
|
Author: roy
Date: 2009-09-19 15:15:22 +0200 (Sat, 19 Sep 2009)
New Revision: 419
Modified:
src/main/java/nl/improved/sqlclient/SQLCommand.java
Log:
fix escaping command
Modified: src/main/java/nl/improved/sqlclient/SQLCommand.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLCommand.java 2009-09-19 12:55:14 UTC (rev 418)
+++ src/main/java/nl/improved/sqlclient/SQLCommand.java 2009-09-19 13:15:22 UTC (rev 419)
@@ -107,6 +107,8 @@
while ( (lastIndex = returnString.indexOf('@', lastIndex)) > 0) {
returnValue.append(returnString.substring(previous, lastIndex));
if (getQuoteCount(returnValue) %2 == 1) {
+ returnValue.append(returnString.charAt(lastIndex));
+ lastIndex++;
previous = lastIndex;
continue;
}
|
|
From: SVN by r. <sv...@ca...> - 2009-09-22 18:55:09
|
Author: roy
Date: 2009-09-22 20:54:54 +0200 (Tue, 22 Sep 2009)
New Revision: 421
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
Log:
fix 'force exit' when spool is used wrongly
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-09-21 18:55:07 UTC (rev 420)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-09-22 18:54:54 UTC (rev 421)
@@ -1697,7 +1697,9 @@
public CommandResult execute(SQLCommand cmd) {
String command = cmd.getCommandString();
String nextPart = command.substring("spool".length()).trim();
- if (nextPart.equalsIgnoreCase("off")) {
+ if (nextPart.equalsIgnoreCase("")) {
+ return new SimpleCommandResult(false, "Please provide a valid argument. See 'help spool' for more information");
+ } else if (nextPart.equalsIgnoreCase("off")) {
if (spoolWriter != null) {
try {
spoolWriter.close();
|
|
From: SVN by r. <sv...@ca...> - 2009-10-16 14:13:04
|
Author: roy
Date: 2009-10-16 16:12:51 +0200 (Fri, 16 Oct 2009)
New Revision: 427
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
src/main/java/nl/improved/sqlclient/QueryExecutor.java
Log:
don't display 'More...' in spool file
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-09-30 18:14:51 UTC (rev 426)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-10-16 14:12:51 UTC (rev 427)
@@ -425,6 +425,9 @@
Iterator<CharSequence> iResult = result.getResult();
while (iResult.hasNext()) {
output(iResult.next());
+ if (iResult.hasNext()) {
+ output("More...\n", false);
+ }
repaint();
}
if (!result.executedSuccessfully()) {
@@ -446,6 +449,9 @@
Iterator<CharSequence> iResult = result.getResult();
while (iResult.hasNext()) {
output(iResult.next());
+ if (iResult.hasNext()) {
+ output("More...\n", false);
+ }
repaint();
}
if (!result.executedSuccessfully()) {
@@ -802,10 +808,13 @@
* @param data the data to print to the screen.
*/
protected void output(CharSequence data) {
+ output(data, true);
+ }
+ protected void output(CharSequence data, boolean spool) {
synchronized(this) {
List<CharSequence> screenBuffer = screen.getScreenBuffer();
screenBuffer.addAll(getLines(data));
- if (spoolWriter != null) {
+ if (spoolWriter != null && spool) {
try {
spoolWriter.write(data.toString());
spoolWriter.write("\n");
Modified: src/main/java/nl/improved/sqlclient/QueryExecutor.java
===================================================================
--- src/main/java/nl/improved/sqlclient/QueryExecutor.java 2009-09-30 18:14:51 UTC (rev 426)
+++ src/main/java/nl/improved/sqlclient/QueryExecutor.java 2009-10-16 14:12:51 UTC (rev 427)
@@ -27,8 +27,6 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Iterator;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import nl.improved.sqlclient.util.ResultBuilder;
/**
@@ -193,6 +191,7 @@
private long start;
private ResultSetMetaData metadata;
private boolean next = true;
+ private boolean first = true;
public QueryExecutorIterator(long start, ResultSet results, List<String> labels, ResultSetMetaData metadata) throws SQLException {
this.start = start;
@@ -212,7 +211,10 @@
try {
next = false;
ResultBuilder displayValue = new ResultBuilder();
- displayValue.setHeader(labels);
+ if (first) {
+ displayValue.setHeader(labels);
+ first = false;
+ }
int max = 1000;
while (results.next() && !cancelled) {
for (int col = 1; col <= columnCount; col++ ) {
@@ -238,8 +240,6 @@
}
footer.append("Query took: "+ (System.currentTimeMillis() - start) +" millis\n\n");
displayValue.setFooter(footer);
- } else {
- displayValue.setFooter("More...\n\n");
}
return displayValue.toString();
} catch(SQLException e) {
|
|
From: SVN by r. <sv...@ca...> - 2009-12-16 10:05:00
|
Author: roy
Date: 2009-12-16 11:04:43 +0100 (Wed, 16 Dec 2009)
New Revision: 437
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
Log:
made repaint public
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-12-16 09:49:10 UTC (rev 436)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-12-16 10:04:43 UTC (rev 437)
@@ -499,7 +499,7 @@
/**
* Repaint the screen.
*/
- protected void repaint() {
+ public void repaint() {
if (isRunning()) {
waitAndPaint();
//paint(getScreen());
|
|
From: SVN by r. <sv...@ca...> - 2010-01-24 13:55:09
|
Author: roy
Date: 2010-01-24 14:48:20 +0100 (Sun, 24 Jan 2010)
New Revision: 457
Modified:
src/main/java/nl/improved/sqlclient/SQLProperties.java
Log:
fix version in help
Modified: src/main/java/nl/improved/sqlclient/SQLProperties.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLProperties.java 2010-01-24 13:24:57 UTC (rev 456)
+++ src/main/java/nl/improved/sqlclient/SQLProperties.java 2010-01-24 13:48:20 UTC (rev 457)
@@ -55,7 +55,7 @@
try {
Properties pomProps = new Properties();
pomProps.load(getClass().getResourceAsStream("/META-INF/maven/nl.improved/sqlshell/pom.properties"));
- props.put(PropertyName.VERSION, props.get("version"));
+ props.put(PropertyName.VERSION.name(), pomProps.get("version"));
} catch(Exception e) {
//System.err.println("Failed to load pom.properties");
}
|
|
From: SVN by r. <sv...@ca...> - 2010-03-08 21:00:40
|
Author: roy
Date: 2010-03-08 21:33:49 +0100 (Mon, 08 Mar 2010)
New Revision: 468
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
src/main/java/nl/improved/sqlclient/SQLProperties.java
Log:
allow for setting to make \n insert a line
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2010-01-29 11:05:26 UTC (rev 467)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2010-03-08 20:33:49 UTC (rev 468)
@@ -325,7 +325,7 @@
}
StringBuffer lineBuffer = getEditableCommand().getEditableLines().get(cursorPosition.y);
int previousBreak = SQLUtil.getLastBreakIndex(lineBuffer.substring(0, cursorPosition.x-1));
- if (lineBuffer.charAt(previousBreak) == ' ' || lineBuffer.charAt(previousBreak) == '\t') {
+ if (SQLUtil.isBreakCharacter(lineBuffer.charAt(previousBreak))) {
previousBreak++;
}
lineBuffer.delete(previousBreak, cursorPosition.x);
@@ -645,9 +645,27 @@
if (ke != null) {
ke.execute();
} else {
- if (inp.getCharacter() == '\n') { // newline... see if the command can be executed
+ if (inp.getCharacter() == '\n') {
+ //Y : insert a new line when the current line is not the last line
+ SQLCommand sqlCommand = getCommand();
+ if ("Y".equals(SQLProperties.getProperty(SQLProperties.PropertyName.ENTER_AT_END))) {
+ Point cursorPosition = screen.getCursorPosition();
+ if (sqlCommand.getLines().size() -1 > cursorPosition.y) {
+ StringBuffer newLine = new StringBuffer();
+ StringBuffer currentLine = sqlCommand.getEditableLines().get(cursorPosition.y);
+ if (currentLine.length() > cursorPosition.x) {
+ newLine.append(currentLine.substring(cursorPosition.x));
+ currentLine.delete(cursorPosition.x, currentLine.length());
+ }
+ sqlCommand.getEditableLines().add(cursorPosition.y+1, newLine);
+ cursorPosition.x = 0;
+ cursorPosition.y++;
+ repaint();
+ return;
+ }
+ }
+ // newline... see if the command can be executed
// execute the command
- SQLCommand sqlCommand = getCommand();
String command = sqlCommand.getCommandString();
// search command...
if (command.length() > 0 && command.charAt(0) == '/') { // search in history
Modified: src/main/java/nl/improved/sqlclient/SQLProperties.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLProperties.java 2010-01-29 11:05:26 UTC (rev 467)
+++ src/main/java/nl/improved/sqlclient/SQLProperties.java 2010-03-08 20:33:49 UTC (rev 468)
@@ -25,7 +25,7 @@
public class SQLProperties {
- public static enum PropertyName {VERSION, CONFIG_VERSION, MOUSE_HANDLING};
+ public static enum PropertyName {VERSION, CONFIG_VERSION, ENTER_AT_END};
private static SQLProperties instance;
|
|
From: SVN by r. <sv...@ca...> - 2010-05-07 08:44:11
|
Author: roy
Date: 2010-05-07 10:17:22 +0200 (Fri, 07 May 2010)
New Revision: 470
Modified:
src/main/java/nl/improved/sqlclient/QueryExecutor.java
Log:
fixes for postgres
don't leave connection in an unusable state when a statement failed.
call rollback on savepoint
Modified: src/main/java/nl/improved/sqlclient/QueryExecutor.java
===================================================================
--- src/main/java/nl/improved/sqlclient/QueryExecutor.java 2010-03-08 20:34:54 UTC (rev 469)
+++ src/main/java/nl/improved/sqlclient/QueryExecutor.java 2010-05-07 08:17:22 UTC (rev 470)
@@ -15,10 +15,12 @@
*/
package nl.improved.sqlclient;
+import java.sql.Connection;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
+import java.sql.Savepoint;
import java.sql.Time;
import java.sql.Timestamp;
import java.sql.Types;
@@ -163,23 +165,37 @@
* @return the formatted result.
* @throws SQLException if the database could not execute the SQL query for some reason.
*/
+ private static int savePointCounter = 0;
public Iterator<CharSequence> executeQuery(CharSequence command) throws SQLException {
cancelled = false;
long start = System.currentTimeMillis();
- ResultSet results = DBConnector.getInstance().getStatement().executeQuery(command.toString());
+ Connection con = DBConnector.getInstance().getConnection();
+ Savepoint savePoint = null;
+ if (!con.getAutoCommit()) {
+ String savePointName = "SavePoint"+(++savePointCounter);
+ savePoint = con.setSavepoint(savePointName);
+ }
+ try {
+ ResultSet results = DBConnector.getInstance().getStatement().executeQuery(command.toString());
- //StringBuffer separator = new StringBuffer();
- //StringBuffer displayValue = new StringBuffer();
+ //StringBuffer separator = new StringBuffer();
+ //StringBuffer displayValue = new StringBuffer();
- ResultSetMetaData metadata = results.getMetaData();
+ ResultSetMetaData metadata = results.getMetaData();
- // TODO specify labels
- List<String> labels = new ArrayList<String>();
- for ( int col = 1; col <= metadata.getColumnCount(); col++) {
- labels.add(metadata.getColumnLabel(col));
+ // TODO specify labels
+ List<String> labels = new ArrayList<String>();
+ for ( int col = 1; col <= metadata.getColumnCount(); col++) {
+ labels.add(metadata.getColumnLabel(col));
+ }
+
+ return new QueryExecutorIterator(start, results, labels, metadata);
+ } catch(SQLException e) {
+ if (savePoint != null) {
+ try {con.rollback(savePoint);} catch(SQLException ex) {}
+ }
+ throw e;
}
-
- return new QueryExecutorIterator(start, results, labels, metadata);
}
private class QueryExecutorIterator implements Iterator<CharSequence> {
|
|
From: SVN by r. <sv...@ca...> - 2010-07-25 10:46:21
|
Author: roy
Date: 2010-07-25 12:46:11 +0200 (Sun, 25 Jul 2010)
New Revision: 479
Modified:
src/main/java/nl/improved/sqlclient/QueryExecutor.java
Log:
catch error
Modified: src/main/java/nl/improved/sqlclient/QueryExecutor.java
===================================================================
--- src/main/java/nl/improved/sqlclient/QueryExecutor.java 2010-07-25 10:01:52 UTC (rev 478)
+++ src/main/java/nl/improved/sqlclient/QueryExecutor.java 2010-07-25 10:46:11 UTC (rev 479)
@@ -99,6 +99,13 @@
* @return the formatted value to display
*/
private CharSequence getDisplayValue(ResultSet rset, int column) throws SQLException {
+ try {
+ return getDisplayValueInternal(rset, column);
+ } catch(SQLException e) {
+ return "***ERR***";
+ }
+ }
+ private CharSequence getDisplayValueInternal(ResultSet rset, int column) throws SQLException {
ResultSetMetaData metadata = rset.getMetaData();
switch (metadata.getColumnType(column)) {
|