You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(8) |
Oct
(34) |
Nov
(7) |
Dec
(2) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(29) |
Feb
(10) |
Mar
(14) |
Apr
(4) |
May
(2) |
Jun
|
Jul
(14) |
Aug
(25) |
Sep
(6) |
Oct
(18) |
Nov
(4) |
Dec
(14) |
2009 |
Jan
(28) |
Feb
(15) |
Mar
(15) |
Apr
(8) |
May
|
Jun
|
Jul
(1) |
Aug
(4) |
Sep
(12) |
Oct
(1) |
Nov
|
Dec
(22) |
2010 |
Jan
(14) |
Feb
|
Mar
(2) |
Apr
|
May
(7) |
Jun
|
Jul
(3) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: SVN by r. <sv...@ca...> - 2009-02-20 20:46:54
|
Author: roy Date: 2009-02-20 21:46:47 +0100 (Fri, 20 Feb 2009) New Revision: 376 Modified: makejars.sh Log: make 0.7 Modified: makejars.sh =================================================================== --- makejars.sh 2009-02-20 20:46:01 UTC (rev 375) +++ makejars.sh 2009-02-20 20:46:47 UTC (rev 376) @@ -1,6 +1,6 @@ #!/bin/bash PROJECT=sqlshell -VERSION=0.6 +VERSION=0.7 #cleanup rm -Rf release @@ -37,7 +37,7 @@ cp ../src/main/resources/db.properties bin cp ../target/*.jar bin/${PROJECT}.jar cp -Rf ../lib bin -cp -Rf ../windows bin +#cp -Rf ../windows bin #cp -Rf ${HOME}/.m2/repository/hsqldb/hsqldb/1.8.0/hsqldb-1.8.0.jar bin/lib mkdir bin/db cp -Rf ../db/*.script bin/db |
From: SVN by r. <sv...@ca...> - 2009-02-20 20:46:10
|
Author: roy Date: 2009-02-20 21:46:01 +0100 (Fri, 20 Feb 2009) New Revision: 375 Modified: sqlshell sqlshell.bat Log: fix startup files removed dll/so file depending on host system (.sh file or bat file) Modified: sqlshell =================================================================== --- sqlshell 2009-02-20 20:45:25 UTC (rev 374) +++ sqlshell 2009-02-20 20:46:01 UTC (rev 375) @@ -47,7 +47,8 @@ CP=${CP}:${DRIVER} done +#unix source.. cleanup windows dll +rm ${WORKINGDIR}/lib/jcurses/*.dll #Enable the file below to use the jcurses version #${JAVA} -cp ${CP} nl.improved.sqlclient.jcurses.SQLShell $@ -#Charva version ${JAVA} -Djava.library.path=${CHARVA} -cp ${CP} nl.improved.sqlclient.SQLShell $@ Modified: sqlshell.bat =================================================================== --- sqlshell.bat 2009-02-20 20:45:25 UTC (rev 374) +++ sqlshell.bat 2009-02-20 20:46:01 UTC (rev 375) @@ -13,20 +13,21 @@ REM limitations under the License. REM Dir to use as base for relative locations -set WORKINGDIR=y:\sqlshell\sqlclient\ +set WORKINGDIR=y:\sqlshell\ REM The directory where the JCurses jar and library are located. REM Please note that JCurses requires tje jcurses.jar and libjcurses.so to REM be located in the same directory. -set JCURSES=%WORKINGDIR%\lib REM Where to find the SQLShell classes -set SQLSHELL=%WORKINGDIR%\target\sqlshell-0.6.jar +set SQLSHELL=%WORKINGDIR%\sqlshell.jar -# REM providing drivers for the databases to support. +REM providing drivers for the databases to support. set DRIVERS="%WORKINGDIR%\lib\hsqldb-1.8.0.jar" REM The classpath to use when running -set CP=%WORKINGDIR%;%SQLSHELL%;%JCURSES%\jcurses.jar;%WORKINGDIR%\lib\charva\charva.jar;%WORKINGDIR%\lib\commons-logging.jar +set CP=%WORKINGDIR%;%SQLSHELL%;%WORKINGDIR%\lib\jcurses\jcurses.jar;%WORKINGDIR%\lib\charva\charva.jar;%WORKINGDIR%\lib\commons-logging.jar -java -Djava.library.path=%WORKINGDIR%\lib\charva -classpath %CP%;%DRIVERS% nl.improved.sqlclient.jcurses.SQLShell +#windows source.. cleanup unix so files +del %WORKINGDIR%\lib\jcurses\*.so +java -Djava.library.path=%WORKINGDIR%\lib\charva;%WORKINGDIR%\lib\jcurses -classpath %CP%;%DRIVERS% nl.improved.sqlclient.SQLShell %* |
From: SVN by r. <sv...@ca...> - 2009-02-20 20:45:32
|
Author: roy Date: 2009-02-20 21:45:25 +0100 (Fri, 20 Feb 2009) New Revision: 374 Modified: src/main/java/nl/improved/sqlclient/SQLProperties.java Log: make sure the config dir exists Modified: src/main/java/nl/improved/sqlclient/SQLProperties.java =================================================================== --- src/main/java/nl/improved/sqlclient/SQLProperties.java 2009-02-18 22:19:47 UTC (rev 373) +++ src/main/java/nl/improved/sqlclient/SQLProperties.java 2009-02-20 20:45:25 UTC (rev 374) @@ -89,6 +89,8 @@ defaultProps.put(key, currentProps.getProperty((String)key)); } } + File f = getPropertyFile(); + f.getParentFile().mkdirs(); defaultProps.save(new FileOutputStream(getPropertyFile()), "SQLShell properties file"); } } |
From: SVN by r. <sv...@ca...> - 2009-02-18 23:56:33
|
Author: ronald Date: 2009-02-18 23:09:42 +0100 (Wed, 18 Feb 2009) New Revision: 372 Added: src/www/content/contact.txt src/www/content/download.txt src/www/content/home.txt src/www/content/screenshots.txt src/www/include/loadContent.php Removed: src/www/include/faq.php Modified: src/www/content/faq.txt src/www/content/news.txt src/www/design/style.css src/www/include/javascript.js Log: website update Added: src/www/content/contact.txt =================================================================== --- src/www/content/contact.txt 2009-01-26 08:44:29 UTC (rev 371) +++ src/www/content/contact.txt 2009-02-18 22:09:42 UTC (rev 372) @@ -0,0 +1,3 @@ +<p>hglteam at users.sourceforge.net </p> +<p>vdkuil at users.sourceforge.net </p> +<p>srotman at users.sourceforge.net </p> \ No newline at end of file Added: src/www/content/download.txt =================================================================== --- src/www/content/download.txt 2009-01-26 08:44:29 UTC (rev 371) +++ src/www/content/download.txt 2009-02-18 22:09:42 UTC (rev 372) @@ -0,0 +1,6 @@ +<p>download <a href="http://sourceforge.net/project/showfiles.php?group_id=204538&package_id=244099&release_id=649412" target="_blank">here</a> the last version</p> +<h2>Installation</h2> +Minimum (tested) requirements: SUN Java 6 and a working operating system for +javacurses (http://sf.net/projects/javacurses) +<h2>Source </h2> +<p>Download <a href="http://sourceforge.net/project/showfiles.php?group_id=204538" target="_blank">releases from Sourceforge </a> </p> \ No newline at end of file Modified: src/www/content/faq.txt =================================================================== --- src/www/content/faq.txt 2009-01-26 08:44:29 UTC (rev 371) +++ src/www/content/faq.txt 2009-02-18 22:09:42 UTC (rev 372) @@ -1,10 +1,39 @@ -Q:Which features has SQLShell? -The goal of SQLShell is to be as usefull as possible in a shell environment. Currently it supports many features like: tabcompletion on tables and columns, command history, spooling of files, executing a sql script -Q:How to run SQLShell -Unzip the tgz or zip file and start sql shell using: -windows: sqlshell.bat<br>unix/linux: ./sqlshell -Per default is uses a simple database, you can configure your own database settings by editing the db.properties file -Q:How to connect to database -With the command connect. The command 'help connect' provides a list of configured identities -Q:Why develop something like SQLShell -Since it is not always possible to use a graphical client for performing sql queries on a server it is really usefull to use a sqlclient that works in a non graphic environment. Most sqlclients I have used have different plus points. But the negative parts are usually too big to be usefull. On a side note when you use different database engines it would nice if it is possible to use one client for all. Hopefully SQLShell will solve these problems for you as well as it did (and does) for me. +Q:Which features has SQLShell? +The goal of SQLShell is to be as usefull as possible in a shell environment. +Currently it supports many features like: tabcompletion on tables and columns, command history, spooling of files, executing a sql script + +Q:What are the requirements +Minimum (tested) requirements: SUN Java 6 and a working operating system for: +javacurses (http://sf.net/projects/javacurses) +or charva (http://www.pitman.co.za/projects/charva/index.html). + +Q:How to run SQLShell +Unzip the tgz or zip file and start sql shell using: +windows: sqlshell.bat<br>unix/linux: ./sqlshell +Per default is uses a simple database, you can configure your own database settings by editing the db.properties file + +With Charva +In order to run sqlshell using charva you need to have the charva libraries in the lib folder. +Currently charva is compiled for windows (32 bits) and linux intel 32 bits and amd 64 bits. If you don't +own an intel 32 bits, you need to modify the contents of the lib/charva directory. + +With JCurses +Please note that in order to be able to run the improved sqlclient +with the 'sqlshell' script, the $project/lib dir is required to +contain the jcurses.jar and libjcurses.so files. +Also note that jcurses.jar need NOT be a symlink. + +Windows: +1. Copy or move the dll located in the windows directory to the lib directory (the directory containing jcurses.jar +2. Change the INSTALLATION_DIR variable in sqlshell.bat file +3. Start sqlshell.bat + +Q:How to connect to my database +With the command connect. The command 'help connect' provides a list of configured identities + +Q:Why develop something like SQLShell +The intention of writing this sqlclient/sqlshell is to provide a common interface to different databases we use in our company. But most important is that the interface to a commercial client we use is really not very usefull. Our goal is to add as many features as we can think of to this small utility class so that our daily work is made a lot easier. The initial functionality should contain: +- sql command history (key up/down) +- tab completion (at least for select queries) +- execute a sql file (@mystatements.sql) +- spool output to a file (spool output.txt) Added: src/www/content/home.txt =================================================================== --- src/www/content/home.txt 2009-01-26 08:44:29 UTC (rev 371) +++ src/www/content/home.txt 2009-02-18 22:09:42 UTC (rev 372) @@ -0,0 +1,10 @@ + +A fully functional smart textual database frontend with features like tabcompletion and command history. +All the missing unix tool features in sqlplus or server commandline are include in sqlshell and many many more. +SQLShell is trying to be as much self-explanatory as possible. To accomplish this SQLShell has: +* an embedded help function that allows you to show help about a specific command or search for a keyword in help (help -k keyword). +* tab completion assist for most commands (including file browsing for spool or executing a command from file (@) + +SQLShell is getting new features with every new release and it's tab completion support for sql queries has improved a lot since it's first release. <br> +A fully functional smart textual database frontend with features like tabcompletion and command history.<br> +All the missing unix tool features in sqlplus or servercommandline are include in sqlshell. Modified: src/www/content/news.txt =================================================================== --- src/www/content/news.txt 2009-01-26 08:44:29 UTC (rev 371) +++ src/www/content/news.txt 2009-02-18 22:09:42 UTC (rev 372) @@ -1,5 +1,7 @@ -2007-10-09 <a href="http://sourceforge.net/forum/forum.php?forum_id=743419" target="_blank">release 0.3</a> -2007-09-16 <a href="http://sourceforge.net/forum/forum.php?forum_id=736699" target="_blank">release 0.2</a> -2007-09-15 release of website -2007-09-07 start design website -2007-08-01 <a href="http://sourceforge.net/forum/forum.php?forum_id=731541" target="_blank">release 0.1</a> +2008-12-24 release 0.6.1 +2008-12-23 release 0.6 +2008-03-14 release 0.5 +2008-01-24 release 0.4 +2007-10-09 release 0.3 +2007-09-16 release 0.2 +2007-08-01 release 0.1 Added: src/www/content/screenshots.txt =================================================================== --- src/www/content/screenshots.txt 2009-01-26 08:44:29 UTC (rev 371) +++ src/www/content/screenshots.txt 2009-02-18 22:09:42 UTC (rev 372) @@ -0,0 +1,10 @@ +<img src="content/screenshots/help.jpg" name="screenshot_large" width="514" height="406" align="left"> +<div class="screenshot"> +<img src="content/screenshots/help.jpg" onClick="showScreenshot(this)" width="140" height="110">overview of commands available shown in help +</div> +<div class="screenshot"> +<img src="content/screenshots/choose_columnname.jpg" onClick="showScreenshot(this)" width="140" height="110">a popup dialog for choosing column names +</div> +<div class="screenshot"> +<img src="content/screenshots/multiple_values_possible.jpg" onClick="showScreenshot(this)" width="140" height="110">a popup dialog shows up when no single value is possible +</div> \ No newline at end of file Modified: src/www/design/style.css =================================================================== --- src/www/design/style.css 2009-01-26 08:44:29 UTC (rev 371) +++ src/www/design/style.css 2009-02-18 22:09:42 UTC (rev 372) @@ -38,6 +38,7 @@ div.content { position:absolute; left: 150px; + right: 150px; top : 100px; } Deleted: src/www/include/faq.php =================================================================== --- src/www/include/faq.php 2009-01-26 08:44:29 UTC (rev 371) +++ src/www/include/faq.php 2009-02-18 22:09:42 UTC (rev 372) @@ -1,12 +0,0 @@ -<?php -$faqRows = file("content/faq.txt"); -foreach ($faqRows as $faqRow) { - echo "<p>"; - if (substr($faqRow, 0, 1)=="Q") { - echo "<b>".$faqRow."</b>"; - } else { - echo $faqRow; - } - echo "<p>"; -} -?> \ No newline at end of file Modified: src/www/include/javascript.js =================================================================== --- src/www/include/javascript.js 2009-01-26 08:44:29 UTC (rev 371) +++ src/www/include/javascript.js 2009-02-18 22:09:42 UTC (rev 372) @@ -1,5 +1,5 @@ function showTab(boxid) { - hideTabs(); + hideTabs(); var tab = document.getElementById(boxid); tab.style.visibility="visible"; tab.style.display="block"; Copied: src/www/include/loadContent.php (from rev 371, src/www/include/faq.php) =================================================================== --- src/www/include/faq.php 2009-01-26 08:44:29 UTC (rev 371) +++ src/www/include/loadContent.php 2009-02-18 22:09:42 UTC (rev 372) @@ -0,0 +1,16 @@ +<?php +$faqRows = file("content/$page.txt"); +foreach ($faqRows as $faqRow) { + if (substr($faqRow, 0, 1)=="Q") { + echo "<br><b>".$faqRow."</b>"; + } else if (trim($faqRow)=="") { + echo "</p><p>"; + } else { + echo $faqRow; + } + if ($page!=="screenshots") { + //quick workaround + echo "<br>"; + } +} +?> \ No newline at end of file Property changes on: src/www/include/loadContent.php ___________________________________________________________________ Name: svn:mergeinfo + |
From: SVN by r. <sv...@ca...> - 2009-02-18 23:21:56
|
Author: ronald Date: 2009-02-18 23:19:47 +0100 (Wed, 18 Feb 2009) New Revision: 373 Modified: src/www/index.php Log: update website Modified: src/www/index.php =================================================================== --- src/www/index.php 2009-02-18 22:09:42 UTC (rev 372) +++ src/www/index.php 2009-02-18 22:19:47 UTC (rev 373) @@ -1,4 +1,4 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>SQLShell</title> @@ -10,59 +10,66 @@ <body> <div class="logo"></div> <div class="menu"> - <a href="#" onClick="showTab('Home')">Home</a> | <a href="#" onClick="showTab('FAQ')">FAQ</a> - | <a href="#" onClick="showTab('Screenshots')">Screenshots</a> | <a href="#" onClick="showTab('Download')">Download</a> - | <a href="#" onClick="showTab('Contact')">Contact</a> -</div> -<div class="content"> - <div id="Home" class="page"> - <h1>SQLShell: </h1> - <p>A fully functional smart textual database frontend with features like tabcompletion - and command history.<br> - All the missing unix tool features in sqlplus or servercommandline are include - in sqlshell. </p> + <a href="#" onClick="showTab('Home')">Home</a> | <a href="#" onClick="showTab('FAQ')">FAQ</a> + | <a href="#" onClick="showTab('Screenshots')">Screenshots</a> | <a href="#" onClick="showTab('Download')">Download</a> + | <a href="#" onClick="showTab('Contact')">Contact</a> +</div> +<div class="content"> + + <div id="Home" class="page"> + <h1>SQLShell:</h1> + <p> + <?php + $page = "home"; + include "include/loadContent.php"; + ?> + </p> <p> </p> - <h1>News</h1> - <ul> - <?php include "include/news.php"; ?> - </ul> + <h1>News</h1> + <ul> + <?php include "include/news.php"; ?> + </ul> </div> - <div id="FAQ" class="page"> - <h1 align="left">FAQ</h1> - <?php include "include/faq.php"; ?> + + <div id="FAQ" class="page"> + <h1 align="left">FAQ</h1> + <p> + <?php + $page = "faq"; + include "include/loadContent.php"; + ?> + </p> </div> - <div id="Screenshots" class="page"> + + <div id="Screenshots" class="page"> <h1>Screenshots</h1> - <img src="content/screenshots/help.jpg" name="screenshot_large" width="514" height="406" align="left"> - <div class="screenshot"> <img src="content/screenshots/help.jpg" onClick="showScreenshot(this)" width="140" height="110"><br> - overview of commands available shown in help </div> + <?php + $page = "screenshots"; + include "include/loadContent.php"; + ?> + </div> - <div class="screenshot"> <img src="content/screenshots/choose_columnname.jpg" onClick="showScreenshot(this)" width="140" height="110"><br> - a popup dialog for choosing column names </div> - <div class="screenshot"><img src="content/screenshots/multiple_values_possible.jpg" onClick="showScreenshot(this)" width="140" height="110"><br> - a popup dialog shows up when no single value is possible </div> - </div> - <div id="Download" class="page"> + <div id="Download" class="page"> <h1>Download</h1> - <p>download <a href="#">here</a> the last version</p> - <h2>Installation</h2> - Minimum (tested) requirements: SUN Java 6 and a working operating system for - javacurses (http://sf.net/projects/javacurses) - <h2>Source </h2> - <p>Download <a href="http://sourceforge.net/project/showfiles.php?group_id=204538" target="_blank">releases - from Sourceforge </a> </p> + <?php + $page = "download"; + include "include/loadContent.php"; + ?> <?php // <h2>SVN</h2> // <p>svn co svn://dev.cable2000.nl/devel sqlclient </p> ?> <h2> </h2> </div> - <div id="Contact" class="page"> + + <div id="Contact" class="page"> <h1>Contact</h1> - <p>hglteam at users.sourceforge.net </p> - <p> vdkuil at users.sourceforge.net </p> - <p> srotman at users.sourceforge.net </p> + <?php + $page = "contact"; + include "include/loadContent.php"; + ?> </div> +<a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=204538&type=3" width="125" height="37" border="0" alt="SourceForge.net Logo" /></a> </div> </body> </html> |
From: SVN by r. <sv...@ca...> - 2009-01-26 08:44:34
|
Author: roy Date: 2009-01-26 09:44:29 +0100 (Mon, 26 Jan 2009) New Revision: 371 Modified: src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java Log: remove sleep Modified: src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-26 08:42:48 UTC (rev 370) +++ src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-26 08:44:29 UTC (rev 371) @@ -215,11 +215,6 @@ @Override public void close() { frame.hide(); - try { - Thread.sleep(1000); - } catch (InterruptedException ex) { - Logger.getLogger(CharvaSQLShellWindow.class.getName()).log(Level.SEVERE, null, ex); - } super.close(); } |
From: SVN by r. <sv...@ca...> - 2009-01-26 08:42:56
|
Author: roy Date: 2009-01-26 09:42:48 +0100 (Mon, 26 Jan 2009) New Revision: 370 Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java src/main/java/nl/improved/sqlclient/SQLShell.java src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java Log: fixes in exception handling/logging Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-01-26 07:50:33 UTC (rev 369) +++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-01-26 08:42:48 UTC (rev 370) @@ -18,6 +18,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; +import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; @@ -130,10 +131,14 @@ */ private boolean run = true; // set to false on quit private File errFile; + private PrintStream errorStream; + private PrintStream outStream; /** * Constructor. */ public AbstractSQLShellWindow() { + errorStream = System.err; + outStream = System.out; try { errFile = File.createTempFile("sqlshell", ".err"); errFile.deleteOnExit(); @@ -141,6 +146,7 @@ } catch (IOException ex) { Logger.getLogger(AbstractSQLShellWindow.class.getName()).log(Level.SEVERE, null, ex); } + screen = new Screen(); char[] emptyLineChar = new char[getScreenWidth()]; Arrays.fill(emptyLineChar, ' '); @@ -598,6 +604,19 @@ spoolWriter = null; } catch(Exception e) {/*ignore*/} } + System.setErr(errorStream); + System.setOut(outStream); + File errFile = getErrFile(); + if (errFile != null && errFile.length() > 0L) { + try { + System.out.println("There where errors during execution of sqlshell:"); + BufferedReader reader = new BufferedReader(new FileReader(errFile)); + String line; + while ( (line = reader.readLine()) != null) { + System.out.println(line); + } + } catch(Exception e) {} + } } protected File getErrFile() { Modified: src/main/java/nl/improved/sqlclient/SQLShell.java =================================================================== --- src/main/java/nl/improved/sqlclient/SQLShell.java 2009-01-26 07:50:33 UTC (rev 369) +++ src/main/java/nl/improved/sqlclient/SQLShell.java 2009-01-26 08:42:48 UTC (rev 370) @@ -108,8 +108,12 @@ return argsMap; } public static void main(String[] args) throws InterruptedException, IOException { - PrintStream errorStream = System.err; - PrintStream outStream = System.out; + Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + + public void uncaughtException(Thread t, Throwable e) { + //throw new UnsupportedOperationException("Not supported yet."); + } + }); final Map<String, String> argsMap = parseHelp(args); AbstractSQLShellWindow sqlshellWindow; if (argsMap.get(INPUT) != null) { @@ -199,16 +203,5 @@ } } sqlshellWindow.show(); - System.setErr(errorStream); - System.setOut(outStream); - File errFile = sqlshellWindow.getErrFile(); - if (errFile != null && errFile.length() > 0L) { - System.out.println("There where errors during execution of sqlshell:"); - BufferedReader reader = new BufferedReader(new FileReader(errFile)); - String line; - while ( (line = reader.readLine()) != null) { - System.out.println(line); - } - } } } Modified: src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-26 07:50:33 UTC (rev 369) +++ src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-26 08:42:48 UTC (rev 370) @@ -39,6 +39,7 @@ public class CharvaSQLShellWindow extends AbstractSQLShellWindow { private JTextArea textComponent; private OutputStream debugOut; + private JFrame frame; /** * Constructor. @@ -213,8 +214,13 @@ @Override public void close() { + frame.hide(); + try { + Thread.sleep(1000); + } catch (InterruptedException ex) { + Logger.getLogger(CharvaSQLShellWindow.class.getName()).log(Level.SEVERE, null, ex); + } super.close(); - Toolkit.getDefaultToolkit().getTopWindow().hide(); } @@ -366,7 +372,7 @@ } public void show() { - JFrame frame = new JFrame() { + frame = new JFrame() { @Override public void draw() { Modified: src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java 2009-01-26 07:50:33 UTC (rev 369) +++ src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java 2009-01-26 08:42:48 UTC (rev 370) @@ -227,8 +227,8 @@ @Override public void close() { + sqlShell.close(); super.close(); - sqlShell.close(); // TODO } |
From: SVN by r. <sv...@ca...> - 2009-01-26 07:50:41
|
Author: roy Date: 2009-01-26 08:50:33 +0100 (Mon, 26 Jan 2009) New Revision: 369 Modified: src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java Log: cursor location fixes Modified: src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java 2009-01-25 14:19:15 UTC (rev 368) +++ src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java 2009-01-26 07:50:33 UTC (rev 369) @@ -325,9 +325,12 @@ public SQLShellTextComponent() { setColors(new CharColor(CharColor.BLACK, CharColor.WHITE)); setTextComponentColors(new CharColor(CharColor.BLACK, CharColor.WHITE)); + setCursorColors(new CharColor(CharColor.WHITE, CharColor.BLACK)); } public void draw() { if (isVisible()) { + Point cursorLocation = getScreen().getCursorPosition(); + setCursorLocation(cursorLocation.x+Screen.PROMPT.length()+2,cursorLocation.y+getTextHeight()); doRepaint(); } } |
From: SVN by r. <sv...@ca...> - 2009-01-25 14:19:21
|
Author: roy Date: 2009-01-25 15:19:15 +0100 (Sun, 25 Jan 2009) New Revision: 368 Modified: src/main/java/nl/improved/sqlclient/ src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java Log: jcurses paint fixes Property changes on: src/main/java/nl/improved/sqlclient ___________________________________________________________________ Name: svn:ignore - .SQLPlusPlus.java.swp .SQLPlus.java.swp .DBConnector.java.swp .SQLUtil.java.swp .Point.java.swp .SQLLineWrapper.java.swp .SQLOutput.java.swp .QueryExecutor.java.swp .SQLShell.java.swp .AbstractSQLShellWindow.java.swo .AbstractSQLShellWindow.java.swp .TabCompletionInfo.java.swp + .SQLPlusPlus.java.swp .SQLPlus.java.swp .DBConnector.java.swp .SQLUtil.java.swp .Point.java.swp .SQLLineWrapper.java.swp .SQLOutput.java.swp .QueryExecutor.java.swp .SQLShell.java.swp .AbstractSQLShellWindow.java.swo .AbstractSQLShellWindow.java.swp .TabCompletionInfo.java.swp .Screen.java.swp Modified: src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java 2009-01-25 14:00:26 UTC (rev 367) +++ src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java 2009-01-25 14:19:15 UTC (rev 368) @@ -170,7 +170,7 @@ } } - textComponent.setText(newText.toString(), true); + textComponent.setText(newText.toString(), false); new Thread() { @Override @@ -328,21 +328,16 @@ } public void draw() { if (isVisible()) { - Point cursorPos = getScreen().getCursorPosition(); - setCursorLocation(cursorPos.x, cursorPos.y); - //doPaint(); - focus(); // repaints and paints cursor + doRepaint(); } } @Override protected boolean handleInput(InputChar arg0) { - //return super.handleInput(arg0); - //debug("handle input: "+ toInputKey(arg0)); SQLShellWindow.this.handleInput(toInputKey(arg0)); return true; } - } + } } |
From: SVN by r. <sv...@ca...> - 2009-01-25 14:00:33
|
Author: roy Date: 2009-01-25 15:00:26 +0100 (Sun, 25 Jan 2009) New Revision: 367 Modified: ChangeLog Log: mention changes Modified: ChangeLog =================================================================== --- ChangeLog 2009-01-25 13:59:44 UTC (rev 366) +++ ChangeLog 2009-01-25 14:00:26 UTC (rev 367) @@ -1,11 +1,14 @@ 0.7 * Commandline input support + * -engine option to switch between charva (default) and jcurses * Paged command output (no longer out of memory exceptions with large results) * pageup/down bugfix * All kind of sqlcommand parsing fixes in batch ('@') command * Added abort/continue on error options for batch command * Show contents of error file when sqlshell is closed + * Paint issues in charva + * Paint issues in jcurses 0.6.1 (2008-12-24) * Bugfix release for not starting |
From: SVN by r. <sv...@ca...> - 2009-01-25 13:59:51
|
Author: roy Date: 2009-01-25 14:59:44 +0100 (Sun, 25 Jan 2009) New Revision: 366 Modified: src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java Log: a lot of jcurses fixes.. still on some system jcurses works very well.... Modified: src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java 2009-01-25 13:58:39 UTC (rev 365) +++ src/main/java/nl/improved/sqlclient/jcurses/SQLShellWindow.java 2009-01-25 13:59:44 UTC (rev 366) @@ -1,184 +1,255 @@ /* - * Copyright 2008 Roy van der Kuil (ro...@va...) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * To change this template, choose Tools | Templates + * and open the template in the editor. */ + package nl.improved.sqlclient.jcurses; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import jcurses.system.CharColor; import jcurses.system.InputChar; import jcurses.system.Toolkit; +import jcurses.widgets.DefaultLayoutManager; import jcurses.widgets.PopUpMenu; import jcurses.widgets.Window; +import jcurses.widgets.TextComponent; +import jcurses.widgets.WidgetsConstants; import nl.improved.sqlclient.AbstractSQLShellWindow; import nl.improved.sqlclient.InputKey; import nl.improved.sqlclient.Point; -import nl.improved.sqlclient.Screen; import nl.improved.sqlclient.SQLCommand; +import nl.improved.sqlclient.Screen; /** - * SQLShell window based on the jcurses library. - * @see http://jcurses.sourceforge.net/ + * The sqlshell window implementation for jcurses. * @author roy */ public class SQLShellWindow extends AbstractSQLShellWindow { - private Window window; - private boolean dontRepaint = false; - private boolean repaint = true; - private String debugString; + private SQLShellTextComponent textComponent; + private OutputStream debugOut; + private Window sqlShell; - private final Object lockObject = new Object(); - /** - * Default constructor. + * Constructor. + * @param textComponent the text component for rendering the text */ public SQLShellWindow() { + textComponent = new SQLShellTextComponent(); + /*this.textComponent = new TextComponent() { + + @Override + protected boolean handleInput(InputChar arg0) { + //return super.handleInput(arg0); + debug("handle input: "+ toInputKey(arg0)); + SQLShellWindow.this.handleInput(toInputKey(arg0)); + //return super.handleInput(arg0); + doPaint(); + return true; + } + + };*/ + try { + File tmpFile = File.createTempFile("jcurses", ".out"); + tmpFile.deleteOnExit(); + debugOut = new FileOutputStream(tmpFile); + } catch (IOException ex) { + Logger.getLogger(SQLShellWindow.class.getName()).log(Level.SEVERE, null, ex); + } } - /** - * Return the screen width. - * @return the screen width. - */ + private InputKey toInputKey(InputChar inputChar) { + if (inputChar.isSpecialCode()) { + if (inputChar.getCode() == InputChar.KEY_BACKSPACE) { + return new InputKey(InputKey.SpecialKey.BACKSPACE); + } + if (inputChar.getCode() == InputChar.KEY_DC) { + return new InputKey(InputKey.SpecialKey.DELETE); + } + if (inputChar.getCode() == InputChar.KEY_NPAGE) { + return new InputKey(InputKey.SpecialKey.PAGE_DOWN); + } + if (inputChar.getCode() == InputChar.KEY_PPAGE) { + return new InputKey(InputKey.SpecialKey.PAGE_UP); + } + if (inputChar.getCode() == InputChar.KEY_LEFT) { + return new InputKey(InputKey.SpecialKey.LEFT); + } + if (inputChar.getCode() == InputChar.KEY_RIGHT) { + return new InputKey(InputKey.SpecialKey.RIGHT); + } + if (inputChar.getCode() == InputChar.KEY_DOWN) { + return new InputKey(InputKey.SpecialKey.DOWN); + } + if (inputChar.getCode() == InputChar.KEY_UP) { + return new InputKey(InputKey.SpecialKey.UP); + } + if (inputChar.getCode() == InputChar.KEY_HOME) { + return new InputKey(InputKey.SpecialKey.HOME); + } + if (inputChar.getCode() == InputChar.KEY_END) { + return new InputKey(InputKey.SpecialKey.END); + } + return new InputKey(InputKey.SpecialKey.UNKNOWN); + } + return new InputKey(inputChar.getCharacter()); + } + @Override public int getScreenWidth() { return Toolkit.getScreenWidth(); } - /** - * Return the screen height. - * @return the screen height. - */ @Override public int getScreenHeight() { - return Toolkit.getScreenHeight(); + return Toolkit.getScreenHeight()-1; } /** - * Write a debug string. - * @param debug the debug to output + * Force repaint of the screen. */ - @Override - public void debug(String debug) { - debugString = debug; - repaint = true; + void repaintScreen() { + paint(getScreen()); } - - /** - * Set the window to be visible. - */ - public void show() { - if (window == null) { - window = new Window(getScreenWidth(), getScreenHeight(), true, "SQLShell") { - @Override - protected void handleInput(InputChar inputChar) { - SQLShellWindow.this.handleInput(toInputKey(inputChar)); - } - /** - * Paint the screen. - */ - @Override - protected synchronized void paint() { - SQLShellWindow.this.repaint(); - } - - private InputKey toInputKey(InputChar inputChar) { - if (inputChar.isSpecialCode()) { - if (inputChar.getCode() == InputChar.KEY_BACKSPACE) { - return new InputKey(InputKey.SpecialKey.BACKSPACE); - } - if (inputChar.getCode() == InputChar.KEY_DC) { - return new InputKey(InputKey.SpecialKey.DELETE); - } - if (inputChar.getCode() == InputChar.KEY_NPAGE) { - return new InputKey(InputKey.SpecialKey.PAGE_DOWN); - } - if (inputChar.getCode() == InputChar.KEY_PPAGE) { - return new InputKey(InputKey.SpecialKey.PAGE_UP); - } - if (inputChar.getCode() == InputChar.KEY_LEFT) { - return new InputKey(InputKey.SpecialKey.LEFT); - } - if (inputChar.getCode() == InputChar.KEY_RIGHT) { - return new InputKey(InputKey.SpecialKey.RIGHT); - } - if (inputChar.getCode() == InputChar.KEY_DOWN) { - return new InputKey(InputKey.SpecialKey.DOWN); - } - if (inputChar.getCode() == InputChar.KEY_UP) { - return new InputKey(InputKey.SpecialKey.UP); - } - if (inputChar.getCode() == InputChar.KEY_HOME) { - return new InputKey(InputKey.SpecialKey.HOME); - } - if (inputChar.getCode() == InputChar.KEY_END) { - return new InputKey(InputKey.SpecialKey.END); - } - return new InputKey(InputKey.SpecialKey.UNKNOWN); + @Override + public void paint(final Screen screen) { + if (screen.getPageUpCount() > 0) { + paintSlow(screen); + return; + } + int totalLineCount = 0; + final StringBuilder newText = new StringBuilder(); + final List<String> commandLines = formatCommandLines(screen.getShowPrompt() + , screen.getEmptyLine(),(List<CharSequence>) getCommand().getLines()); + for (int i = 0; i < commandLines.size(); i++) { + CharSequence seq = commandLines.get(i); + newText.append(seq.toString()); + if (i < commandLines.size()-1) { + newText.append("\n"); + } + totalLineCount++; + } + if (totalLineCount > getScreenHeight()-1) { + totalLineCount = getScreenHeight()-1; + } + int restLines = (getScreenHeight() -1) - totalLineCount; + if (restLines > 0) { + ArrayList<SQLCommand> commandList = new ArrayList<SQLCommand>(getUnprocessedCommands()); + Collections.reverse(commandList); + commandList: for (SQLCommand command : commandList) { + List<? extends CharSequence> lines = command.getLines(); + for (int i = lines.size() -1; i >=0; i--) { + newText.insert(0, lines.get(i) +"\n"); + restLines--; + totalLineCount++; + if(restLines == 0) { + break; } - return new InputKey(inputChar.getCharacter()); } - }; + } } - window.setVisible(true); - // repaint loop - while (isRunning()) { - Screen screen = getScreen(); - if (!dontRepaint && repaint) { - try { - synchronized(this) { - paintImpl(screen); - } - } catch(Throwable t) { - error(t); + if (restLines > 0) { + List<CharSequence> buffer = new ArrayList<CharSequence>(screen.getScreenBuffer()); + for (int i = buffer.size() -1; i>=0; i--) { + newText.insert(0, buffer.get(i)+"\n"); + restLines--; + totalLineCount++; + if(restLines == 0) { + break; } } - try { - synchronized(lockObject) { - lockObject.wait(1000); + } + + textComponent.setText(newText.toString(), true); + new Thread() { + + @Override + public void run() { + if (textComponent != null && textComponent.isVisible()) { + textComponent.draw(); } - } catch (InterruptedException ex) { - /* ignore */ } + + }.start(); + } + public void paintSlow(final Screen screen) { + int totalLineCount = 0; + StringBuilder newText = new StringBuilder(); + for (CharSequence seq: new ArrayList<CharSequence>(screen.getScreenBuffer())) { + newText.append(seq.toString()); + newText.append("\n"); + totalLineCount++; } - super.close(); - //window.close(); - window.hide(); - window.close(); + for (SQLCommand s : new ArrayList<SQLCommand>(getUnprocessedCommands())) { + for (CharSequence seq: s.getLines()) { + newText.append(screen.getEmptyLine().substring(0, Screen.PROMPT.length()) + ">"); + newText.append(seq.toString()); + newText.append("\n"); + totalLineCount++; + } + } + final List<String> commandLines = formatCommandLines(screen.getShowPrompt() + , screen.getEmptyLine(),(List<CharSequence>) getCommand().getLines()); + for (int i = 0; i < commandLines.size(); i++) { + CharSequence seq = commandLines.get(i); + newText.append(seq.toString()); + if (i < commandLines.size()-1) { + newText.append("\n"); + } + totalLineCount++; + } + if (totalLineCount > getScreenHeight()-1) { + totalLineCount = getScreenHeight()-1; + } + final int lineCount = totalLineCount; + final String trimmed = trim(newText, screen.getPageUpCount()); + textComponent.setText(trimmed); +/* Point cursorPos = screen.getCursorPosition(); + try { + int start = textComponent.getLineStartOffset(lineCount - (commandLines.size() - cursorPos.y)); + textComponent.setCaretPosition(start + cursorPos.x + (Screen.PROMPT+" >").length()); + } catch(Exception e) { + debug("ERROR: failed to calculate line end: "+ lineCount +"-"+ cursorPos.y +"/"+ getScreenHeight()); + } + textComponent.draw();*/ + // TODO } - /** - * Close the window. - */ @Override public void close() { - /* - super.close(); - window.close(); - */ + super.close(); + sqlShell.close(); + // TODO } - /** - * Shows a popupwindow to allow the user to make a selection from the list of possible matches. - * @param items the list of possible matches - * @param p the character x/y location to show the popupscreen on - */ @Override + public void beep() { + Toolkit.beep(); + } + + @Override + public void debug(String debug) { + if (debugOut != null) { + try { + debugOut.write((debug + "\n").getBytes()); + } catch (IOException ex) { + Logger.getLogger(SQLShellWindow.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + + @Override public String select(List<String> items, Point p) { try { PopUpMenu menu = new PopUpMenu(p.x,Math.max(2, p.y-items.size()), "Find match"); @@ -186,114 +257,18 @@ while (iMatches.hasNext()) { menu.add(iMatches.next()); } - dontRepaint = true; + //dontRepaint = true; menu.show(); return menu.getSelectedItem(); } finally { - dontRepaint = false; + //dontRepaint = false; } } - /** - * Paint the screen. - * @param screen the screen information to be painted - */ @Override - public void paint(Screen screen) { - if (isRunning()) { - repaint = true; - synchronized(lockObject) { - lockObject.notify(); - } - } - } - - /** - * Actual implementation of the paint screen method. - * This is different from the normal paint method since this will only - * (and should be) called from the main thread to overcome painting errors. - * @param screen the screen to paint - */ - private void paintImpl(Screen screen) { - if (!isRunning()) { - return; - } - synchronized(lockObject) { - CharColor color = new CharColor(CharColor.BLACK, CharColor.WHITE, CharColor.BOLD, CharColor.BOLD); - - List<CharSequence> tmpList = clone(screen.getScreenBuffer()); - - //add prompt - List<SQLCommand> commandList = getUnprocessedCommands(); - //commandList.add(getCommand()); - boolean showPrompt = screen.getShowPrompt(); - for (SQLCommand commandLines : commandList) { - List<CharSequence> currentLines = clone((List<CharSequence>) commandLines.getLines()); - tmpList.addAll(formatCommandLines(showPrompt, screen.getEmptyLine(), currentLines)); - } - List<CharSequence> currentCommandLines = clone((List<CharSequence>) getCommand().getLines()); - tmpList.addAll(formatCommandLines(showPrompt, screen.getEmptyLine(), currentCommandLines)); - int startLine; - if (tmpList.size() > Toolkit.getScreenHeight()-1) { - startLine = tmpList.size() - (Toolkit.getScreenHeight()-1); - if (screen.getPageUpCount() > 0) { - startLine -= (screen.getPageUpCount() * Toolkit.getScreenHeight()/2); - if (startLine < 0) { - startLine = 0; - } - } - } else { - startLine = 0; - } - int lineNr; - for (lineNr = startLine;lineNr < tmpList.size() && lineNr - startLine < Toolkit.getScreenHeight()-1; lineNr++) { - CharSequence linePart = tmpList.get(lineNr); - String line = linePart.length() >= screen.getEmptyLine().length() ? linePart.toString() : linePart + screen.getEmptyLine().substring(linePart.length()); - Toolkit.printString(line - , 0, lineNr-startLine, color); - } - for (int lNr = lineNr; lNr < Toolkit.getScreenHeight(); lNr++) { - Toolkit.printString(screen.getEmptyLine(), 0, lNr, color); - } - - // paint cursor - color = new CharColor(CharColor.BLACK, CharColor.WHITE, CharColor.REVERSE, CharColor.REVERSE); - String cursorChar = " "; - Point cursorPosition = screen.getCursorPosition(); - //SQLCommand commandLines = getCommand(); - if (currentCommandLines.size() > 0) { - String tmp = currentCommandLines.get(cursorPosition.y).toString(); - if (cursorPosition.x < 0) { - debug("Cursor position was: "+ cursorPosition +" fixing"); - cursorPosition.x = 0; - } - if (cursorPosition.x < tmp.length()) { - cursorChar = tmp.substring(cursorPosition.x, cursorPosition.x+1); - } - } - Toolkit.printString(cursorChar, Screen.PROMPT.length() +"> ".length() + cursorPosition.x, lineNr-(currentCommandLines.size() -cursorPosition.y)-startLine, color); - if (debugString != null) { - if (debugString.length() > Toolkit.getScreenWidth()) { - debugString = debugString.substring(0, Toolkit.getScreenWidth()-1); - } - color = new CharColor(CharColor.BLUE, CharColor.YELLOW); - Toolkit.printString(debugString, 1, getScreenHeight()-1, color); - } - repaint = false; - } - } - - /** - * Fetch the login detail information. - * @param username the default username - * @param password the default password - * @return the login credential string array - * @throws java.sql.SQLException - */ - @Override protected String[] getLoginCredentials(String username, String password) throws SQLException { LoginDialog diag = new LoginDialog(username, password); - dontRepaint = true; + //dontRepaint = true; try { diag.show(); if (!diag.endedSuccessfully()) { @@ -301,53 +276,73 @@ } return new String[] {diag.getUsername(), diag.getPassword() }; } finally { - dontRepaint = false; + //dontRepaint = false; } - } + } - /** - * Override to allow painting on the main thread to overcome painting errors. - */ - @Override - protected void repaint() { - if (isRunning()) { - repaint = true; - synchronized(lockObject) { - lockObject.notify(); + private String trim(StringBuilder text, int pageUpCount) { + String strText = text.toString(); + if (strText.indexOf('\n') < 0) { + return strText; + } + int maxHeight = getScreenHeight(); + String[] lines = strText.split("\n"); + if (lines.length <= maxHeight) { + return strText; + } + StringBuilder newString = new StringBuilder(); + int offset = Math.max(0, lines.length - ((pageUpCount +1) * maxHeight)); + boolean endsWithReturn = strText.endsWith("\n"); + for (int i = 0; i < maxHeight; i++) { + newString.append(lines[i+offset]); + if (i+offset < lines.length-1 || endsWithReturn) { + newString.append('\n'); } } + return newString.toString(); } - /** - * Beep. - */ - @Override - public void beep() { - Toolkit.beep(); + public void show() { + sqlShell = new Window(0, 0, Toolkit.getScreenWidth(), Toolkit.getScreenHeight(), false, "SQLShell") { + @Override + protected void handleInput(InputChar arg0) { + //super.handleInput(arg0); + //debug("WINDOW: handle input: "+ toInputKey(arg0)); + SQLShellWindow.this.handleInput(toInputKey(arg0)); + } + }; + + DefaultLayoutManager layout = (DefaultLayoutManager) sqlShell.getRootPanel().getLayoutManager(); + + layout.addWidget(textComponent, 0, 0, getScreenWidth(), getScreenHeight(), WidgetsConstants.ALIGNMENT_CENTER, WidgetsConstants.ALIGNMENT_CENTER); + repaintScreen(); + sqlShell.pack(); + sqlShell.show(); } - /** - * Clone a list of charsequence to make sure it isn't modified later (during paint). - * @param screenBuffer the screenBuffer to clone - * @return a cloned list of charsequence objects. - */ - private static List<CharSequence> clone(List<CharSequence> screenBuffer) { - List<CharSequence> result = new ArrayList<CharSequence>(screenBuffer.size()); - for(CharSequence cs : screenBuffer) { - result.add(cs.toString()); + public class SQLShellTextComponent extends TextComponent { + + public SQLShellTextComponent() { + setColors(new CharColor(CharColor.BLACK, CharColor.WHITE)); + setTextComponentColors(new CharColor(CharColor.BLACK, CharColor.WHITE)); } - return result; - } + public void draw() { + if (isVisible()) { + Point cursorPos = getScreen().getCursorPosition(); + setCursorLocation(cursorPos.x, cursorPos.y); + //doPaint(); + focus(); // repaints and paints cursor + } + } - public static void main(String[] args) { - SQLShellWindow shell = new SQLShellWindow(); - shell.show(); - //Interpret first argument as a connect argument -/* if (args.length > 0) { - shell.executeCommand(new InputCommand("connect "+args[0])); + @Override + protected boolean handleInput(InputChar arg0) { + //return super.handleInput(arg0); + //debug("handle input: "+ toInputKey(arg0)); + SQLShellWindow.this.handleInput(toInputKey(arg0)); + return true; } - */ - } + } } |
From: SVN by r. <sv...@ca...> - 2009-01-25 13:58:47
|
Author: roy Date: 2009-01-25 14:58:39 +0100 (Sun, 25 Jan 2009) New Revision: 365 Modified: src/main/java/nl/improved/sqlclient/SQLShell.java Log: fix parse error in parsehelp when no arguments provided Modified: src/main/java/nl/improved/sqlclient/SQLShell.java =================================================================== --- src/main/java/nl/improved/sqlclient/SQLShell.java 2009-01-23 16:27:51 UTC (rev 364) +++ src/main/java/nl/improved/sqlclient/SQLShell.java 2009-01-25 13:58:39 UTC (rev 365) @@ -46,6 +46,9 @@ public static Map<String, String> parseHelp(String[] args) throws IOException { Map<String, String> argsMap = new HashMap<String, String>(); + if (args.length == 0) { + return argsMap; + } if (args[0].equals("--help") || args.length %2 == 1) { System.err.println("Usage: "); System.err.println(" java nl.improved.sqlclient.SQLShell [-i inputfile] [-o outputfile] [-engine charva/jcurses]"); |
From: SVN by r. <sv...@ca...> - 2009-01-23 16:28:04
|
Author: roy Date: 2009-01-23 17:27:51 +0100 (Fri, 23 Jan 2009) New Revision: 364 Modified: src/main/java/nl/improved/sqlclient/QueryExecutor.java Log: code cleanup Modified: src/main/java/nl/improved/sqlclient/QueryExecutor.java =================================================================== --- src/main/java/nl/improved/sqlclient/QueryExecutor.java 2009-01-23 16:27:40 UTC (rev 363) +++ src/main/java/nl/improved/sqlclient/QueryExecutor.java 2009-01-23 16:27:51 UTC (rev 364) @@ -167,12 +167,10 @@ //StringBuffer displayValue = new StringBuffer(); ResultSetMetaData metadata = results.getMetaData(); - long start = System.currentTimeMillis(); // TODO specify labels List<String> labels = new ArrayList<String>(); for ( int col = 1; col <= metadata.getColumnCount(); col++) { - StringBuffer labelBuffer = new StringBuffer(); labels.add(metadata.getColumnLabel(col)); } |
From: SVN by r. <sv...@ca...> - 2009-01-23 16:27:48
|
Author: roy Date: 2009-01-23 17:27:40 +0100 (Fri, 23 Jan 2009) New Revision: 363 Modified: src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java Log: code cleanup Modified: src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-23 16:27:25 UTC (rev 362) +++ src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-23 16:27:40 UTC (rev 363) @@ -109,16 +109,16 @@ } int restLines = (getScreenHeight() -1) - totalLineCount; if (restLines > 0) { - ArrayList<SQLCommand> commands = new ArrayList<SQLCommand>(getUnprocessedCommands()); - Collections.reverse(commands); - commands: for (SQLCommand command : commands) { + ArrayList<SQLCommand> commandList = new ArrayList<SQLCommand>(getUnprocessedCommands()); + Collections.reverse(commandList); + commandList: for (SQLCommand command : commandList) { List<? extends CharSequence> lines = command.getLines(); for (int i = lines.size() -1; i >=0; i--) { newText.insert(0, lines.get(i) +"\n"); restLines--; totalLineCount++; if(restLines == 0) { - break commands; + break; } } } |
From: SVN by r. <sv...@ca...> - 2009-01-23 16:27:33
|
Author: roy Date: 2009-01-23 17:27:25 +0100 (Fri, 23 Jan 2009) New Revision: 362 Modified: src/main/java/nl/improved/sqlclient/SQLShell.java Log: added -engine support more help information Modified: src/main/java/nl/improved/sqlclient/SQLShell.java =================================================================== --- src/main/java/nl/improved/sqlclient/SQLShell.java 2009-01-19 15:43:49 UTC (rev 361) +++ src/main/java/nl/improved/sqlclient/SQLShell.java 2009-01-23 16:27:25 UTC (rev 362) @@ -38,21 +38,78 @@ */ public class SQLShell { + public static final String INPUT = "-i"; + public static final String OUTPUT = "-o"; + public static final String ENGINE = "-engine"; + public static final String ENGINE_CHARVA = "charva"; + public static final String ENGINE_JCURSES = "jcurses"; + + public static Map<String, String> parseHelp(String[] args) throws IOException { + Map<String, String> argsMap = new HashMap<String, String>(); + if (args[0].equals("--help") || args.length %2 == 1) { + System.err.println("Usage: "); + System.err.println(" java nl.improved.sqlclient.SQLShell [-i inputfile] [-o outputfile] [-engine charva/jcurses]"); + System.exit(-1); + } + for (int i = 0; i < args.length; i+=2) { + if (args[i].equals(INPUT)) { + if (args.length < i+1) { + System.err.println("Missing filename parameter for -i argument"); + System.exit(-1); + } + File f = new File(args[i+1]); + if (!f.exists()) { + System.err.println("Filename '"+f.getAbsolutePath()+"' does not exist.\nAborting..."); + System.exit(-1); + } + if (!f.canRead()) { + System.err.println("Filename '"+f.getAbsolutePath()+"' cannot be read.\nAborting..."); + System.exit(-1); + } + argsMap.put(args[i], args[i+1]); + } else if (args[i].equals(OUTPUT)) { + if (args.length < i+1) { + System.err.println("Missing filename parameter for -i argument"); + System.exit(-1); + } + File f = new File(args[i+1]); + if (f.exists()) { + if (f.canWrite()) { + System.err.println("Filename already exists.. overwriting"); + } else { + System.err.println("Filename '"+f.getAbsolutePath()+"' cannot be written.\nAborting..."); + System.exit(-1); + } + } else if (f.createNewFile()) { + System.err.println("Filename '"+f.getAbsolutePath()+"' cannot be created.\nAborting..."); + System.exit(-1); + } + argsMap.put(args[i], args[i+1]); + } else if (args[i].equals(ENGINE)) { + if (args.length < i+1) { + System.err.println("Missing engine type parameter for -i argument."); + System.err.println("Possible values are 'jcurses' and 'charva'"); + System.exit(-1); + } + if (!(args[i+1].equals(ENGINE_CHARVA)) && !(args[i+1].equals(ENGINE_JCURSES))) { + System.err.println("Unknown parameter for engine type '"+ args[i+1]+"'"); + System.err.println("Possible values are 'jcurses' and 'charva'"); + System.exit(-1); + } + argsMap.put(args[i], args[i+1]); + } else { + System.err.println("Uknown option: "+ args[i]+"\nAborting..."); + System.exit(-1); + } + } + return argsMap; + } public static void main(String[] args) throws InterruptedException, IOException { PrintStream errorStream = System.err; PrintStream outStream = System.out; - final Map<String, String> argsMap = new HashMap<String, String>(); - if (args.length > 0) { - if (args[0].equals("--help") || args.length %2 == 1) { - System.err.println("Usage: "); - System.exit(-1); - } - for (int i = 0; i < args.length; i+=2) { - argsMap.put(args[i], args[i+1]); - } - } + final Map<String, String> argsMap = parseHelp(args); AbstractSQLShellWindow sqlshellWindow; - if (argsMap.get("-i") != null) { + if (argsMap.get(INPUT) != null) { sqlshellWindow = new AbstractSQLShellWindow() { @Override public int getScreenWidth() { @@ -93,7 +150,7 @@ @Override protected void output(CharSequence data) { - if (!argsMap.containsKey("-o")) { + if (!argsMap.containsKey(OUTPUT)) { System.out.println(data); } } @@ -102,8 +159,8 @@ }; Command cmd = new nl.improved.sqlclient.AbstractSQLShellWindow.ExecuteBatchCommand(sqlshellWindow); CommandResult result = cmd.execute(new SQLCommand("@"+ argsMap.get("-i"))); - if (argsMap.containsKey("-o")) { - File f = new File(argsMap.get("-o")); + if (argsMap.containsKey(OUTPUT)) { + File f = new File(argsMap.get(OUTPUT)); FileOutputStream fout = new FileOutputStream(f); for (CharSequence s : sqlshellWindow.getScreen().getScreenBuffer()) { fout.write(s.toString().getBytes()); @@ -122,9 +179,19 @@ } } else { //sqlshellWindow = new SQLShellWindow(); - try { - sqlshellWindow = new CharvaSQLShellWindow(); - } catch(Error e) { + if (!argsMap.containsKey(ENGINE) || argsMap.get(ENGINE).equals(ENGINE_CHARVA)) { + try { + sqlshellWindow = new CharvaSQLShellWindow(); + } catch(Error e) { + if (!argsMap.containsKey(ENGINE)) { + sqlshellWindow = new SQLShellWindow(); + } else { + System.err.println("Failed to instantiate charva version of sqlshell.\nCaused by: "+ e); + e.printStackTrace(); + return; + } + } + } else { sqlshellWindow = new SQLShellWindow(); } } |
From: SVN by r. <sv...@ca...> - 2009-01-19 15:43:57
|
Author: roy Date: 2009-01-19 16:43:49 +0100 (Mon, 19 Jan 2009) New Revision: 361 Modified: src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java Log: more thread handling Modified: src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-19 14:26:56 UTC (rev 360) +++ src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-19 15:43:49 UTC (rev 361) @@ -158,7 +158,7 @@ SwingUtilities.invokeLater(eventThead); } - public void paintSlow(Screen screen) { + public void paintSlow(final Screen screen) { int totalLineCount = 0; StringBuilder newText = new StringBuilder(); for (CharSequence seq: new ArrayList<CharSequence>(screen.getScreenBuffer())) { @@ -174,7 +174,7 @@ totalLineCount++; } } - List<String> commandLines = formatCommandLines(screen.getShowPrompt() + final List<String> commandLines = formatCommandLines(screen.getShowPrompt() , screen.getEmptyLine(),(List<CharSequence>) getCommand().getLines()); for (int i = 0; i < commandLines.size(); i++) { CharSequence seq = commandLines.get(i); @@ -187,20 +187,28 @@ if (totalLineCount > getScreenHeight()-1) { totalLineCount = getScreenHeight()-1; } - String trimmed = trim(newText, screen.getPageUpCount()); - if (trimmed.startsWith(textComponent.getText())) { - textComponent.append(trimmed.substring(textComponent.getText().length())); - } else { - textComponent.replaceRange(trimmed, 0, textComponent.getText().length()); - } - Point cursorPos = screen.getCursorPosition(); - try { - int start = textComponent.getLineStartOffset(totalLineCount - (commandLines.size() - cursorPos.y)); - textComponent.setCaretPosition(start + cursorPos.x + (Screen.PROMPT+" >").length()); - } catch(Exception e) { - debug("ERROR: failed to calculate line end: "+ totalLineCount +"-"+ cursorPos.y +"/"+ getScreenHeight()); - } - textComponent.draw(); + final int lineCount = totalLineCount; + final String trimmed = trim(newText, screen.getPageUpCount()); + Runnable r = new Runnable() { + + public void run() { + if (trimmed.startsWith(textComponent.getText())) { + textComponent.append(trimmed.substring(textComponent.getText().length())); + } else { + textComponent.replaceRange(trimmed, 0, textComponent.getText().length()); + } + Point cursorPos = screen.getCursorPosition(); + try { + int start = textComponent.getLineStartOffset(lineCount - (commandLines.size() - cursorPos.y)); + textComponent.setCaretPosition(start + cursorPos.x + (Screen.PROMPT+" >").length()); + } catch(Exception e) { + debug("ERROR: failed to calculate line end: "+ lineCount +"-"+ cursorPos.y +"/"+ getScreenHeight()); + } + textComponent.draw(); + } + + }; + SwingUtilities.invokeLater(r); } @Override |
From: SVN by r. <sv...@ca...> - 2009-01-19 14:27:03
|
Author: roy Date: 2009-01-19 15:26:56 +0100 (Mon, 19 Jan 2009) New Revision: 360 Modified: src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java Log: use swingutilities to change text Modified: src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-19 07:50:57 UTC (rev 359) +++ src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2009-01-19 14:26:56 UTC (rev 360) @@ -14,6 +14,7 @@ import charvax.swing.JMenuItem; import charvax.swing.JPopupMenu; import charvax.swing.JTextArea; +import charvax.swing.SwingUtilities; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -85,15 +86,15 @@ } @Override - public void paint(Screen screen) { + public void paint(final Screen screen) { debug("PageUpCount: "+ screen.getPageUpCount()); if (screen.getPageUpCount() > 0) { paintSlow(screen); return; } int totalLineCount = 0; - StringBuilder newText = new StringBuilder(); - List<String> commandLines = formatCommandLines(screen.getShowPrompt() + final StringBuilder newText = new StringBuilder(); + final List<String> commandLines = formatCommandLines(screen.getShowPrompt() , screen.getEmptyLine(),(List<CharSequence>) getCommand().getLines()); for (int i = 0; i < commandLines.size(); i++) { CharSequence seq = commandLines.get(i); @@ -133,19 +134,29 @@ } } } - /*if (newText.toString().startsWith(textComponent.getText())) { - textComponent.append(newText.substring(textComponent.getText().length())); - } else {*/ - textComponent.replaceRange(newText.toString(), 0, textComponent.getText().length()); - //} - Point cursorPos = screen.getCursorPosition(); - try { - int start = textComponent.getLineStartOffset(totalLineCount - (commandLines.size() - cursorPos.y)); - textComponent.setCaretPosition(start + cursorPos.x + (Screen.PROMPT+" >").length()); - } catch(Exception e) { - debug("ERROR: failed to calculate line end: "+ totalLineCount +"-"+ cursorPos.y +"/"+ getScreenHeight()); - } - textComponent.draw(); + + final int lineCount = totalLineCount; + Runnable eventThead = new Runnable() { + + public void run() { + if (newText.toString().startsWith(textComponent.getText())) { + textComponent.append(newText.substring(textComponent.getText().length())); + } else { + textComponent.replaceRange(newText.toString(), 0, textComponent.getText().length()); + } + Point cursorPos = screen.getCursorPosition(); + try { + int start = textComponent.getLineStartOffset(lineCount - (commandLines.size() - cursorPos.y)); + textComponent.setCaretPosition(start + cursorPos.x + (Screen.PROMPT+" >").length()); + } catch(Exception e) { + debug("ERROR: failed to calculate line end: "+ lineCount +"-"+ cursorPos.y +"/"+ getScreenHeight()); + } + textComponent.draw(); + } + + }; + + SwingUtilities.invokeLater(eventThead); } public void paintSlow(Screen screen) { int totalLineCount = 0; |
From: SVN by r. <sv...@ca...> - 2009-01-19 07:51:10
|
Author: roy Date: 2009-01-19 08:50:57 +0100 (Mon, 19 Jan 2009) New Revision: 359 Modified: lib/charva-amd64/libTerminal.so Log: removed mouse handling Modified: lib/charva-amd64/libTerminal.so =================================================================== (Binary files differ) |
From: SVN by r. <sv...@ca...> - 2009-01-17 15:58:08
|
Author: roy Date: 2009-01-17 16:57:58 +0100 (Sat, 17 Jan 2009) New Revision: 358 Modified: ChangeLog Log: mention changes Modified: ChangeLog =================================================================== --- ChangeLog 2009-01-17 15:51:17 UTC (rev 357) +++ ChangeLog 2009-01-17 15:57:58 UTC (rev 358) @@ -1,5 +1,11 @@ 0.7 - * Commandline input support (currently only supported in charva mode) + * Commandline input support + * Paged command output (no longer out of memory exceptions with large + results) + * pageup/down bugfix + * All kind of sqlcommand parsing fixes in batch ('@') command + * Added abort/continue on error options for batch command + * Show contents of error file when sqlshell is closed 0.6.1 (2008-12-24) * Bugfix release for not starting |
From: SVN by r. <sv...@ca...> - 2009-01-17 15:51:25
|
Author: roy Date: 2009-01-17 16:51:17 +0100 (Sat, 17 Jan 2009) New Revision: 357 Modified: README Log: more changes Modified: README =================================================================== --- README 2009-01-17 15:19:18 UTC (rev 356) +++ README 2009-01-17 15:51:17 UTC (rev 357) @@ -11,14 +11,26 @@ javacurses (http://sf.net/projects/javacurses) or charva (http://www.pitman.co.za/projects/charva/index.html). -Linux: +Linux +In the most simple case download the zip file from the sourceforge website +and unzip it to the folder of your liking. Then you can start sqlshell by entering './sqlshell'. +The sqlshell batch script tries to detect it's installation directory. If this doesn't work you +need to manually edit the sqlshell script and change the CURDIR variable. By default it tries +to start the charva version. + +With Charva +In order to run sqlshell using charva you need to have the charva libraries in the lib folder. +Currently charva is compiled for windows (32 bits) and linux intel 32 bits and amd 64 bits. If you don't +own an intel 32 bits, you need to modify the contents of the lib/charva directory. + +With JCurses Please note that in order to be able to run the improved sqlclient with the 'sqlshell' script, the $project/lib dir is required to -contain the jcurses.jar and libjcurses.so files. Also note that -jcurses.jar need NOT be a symlink. +contain the jcurses.jar and libjcurses.so files. +Also note that jcurses.jar need NOT be a symlink. -In the most simple case download the zip or tgz file from the sourceforge website and unzip it to the folder of your liking. Then you can start the programm that is setup to use a simple testdatabase by executing 'sqlshell'. Please note that because of javacurses currently you need to enter the directory in which sqlshell is located before starting it. This is a bug that hopefully we can address really soon. + Windows: 1. Copy or move the dll located in the windows directory to the lib directory (the directory containing jcurses.jar 2. Change the INSTALLATION_DIR variable in sqlshell.bat file |
From: SVN by r. <sv...@ca...> - 2009-01-17 15:19:30
|
Author: roy Date: 2009-01-17 16:19:18 +0100 (Sat, 17 Jan 2009) New Revision: 356 Modified: README Log: some improvements/cleanup Modified: README =================================================================== --- README 2009-01-17 15:15:31 UTC (rev 355) +++ README 2009-01-17 15:19:18 UTC (rev 356) @@ -7,7 +7,9 @@ INSTALLATION -Minimum (tested) requirements: SUN Java 6 and a working operating system for javacurses (http://sf.net/projects/javacurses) +Minimum (tested) requirements: SUN Java 6 and a working operating system for: +javacurses (http://sf.net/projects/javacurses) +or charva (http://www.pitman.co.za/projects/charva/index.html). Linux: Please note that in order to be able to run the improved sqlclient @@ -26,23 +28,17 @@ [See ChangeLog] FUTURE -- dump history to file - show status (query executing, waiting for input... etc) - sort commands in help -- add key bindings in help - add 'show tables like' support - login schreen improvements (select all text on focus) - Improve desc table (to show references, etc) - Improve tab completion for update, delete and alter table queries - Highlight the commands to make a distinction between the output and the commands -- Remember commands over sessions -- Make it possible to export/import data via xml (I think there is even an xml standard for this) - Add config possibility to config: -- command history size -- screen history size -- screen colors -- additional/external commands -- Large query results don't show (> 300.000 rows?) - 'where x' doesn't autocomplete table names - make ctrl+j (for example) auto insert join -- make ctrl+a abort query (ctr c quits application... don't know how to catch that) |
From: SVN by r. <sv...@ca...> - 2009-01-17 15:15:39
|
Author: roy Date: 2009-01-17 16:15:31 +0100 (Sat, 17 Jan 2009) New Revision: 355 Modified: src/main/java/nl/improved/sqlclient/SQLShell.java Log: added output result of batch command from commandline call again Modified: src/main/java/nl/improved/sqlclient/SQLShell.java =================================================================== --- src/main/java/nl/improved/sqlclient/SQLShell.java 2009-01-17 15:11:40 UTC (rev 354) +++ src/main/java/nl/improved/sqlclient/SQLShell.java 2009-01-17 15:15:31 UTC (rev 355) @@ -23,10 +23,12 @@ import java.io.PrintStream; import java.sql.SQLException; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import nl.improved.sqlclient.charva.CharvaSQLShellWindow; import nl.improved.sqlclient.commands.Command; +import nl.improved.sqlclient.commands.CommandResult; import nl.improved.sqlclient.jcurses.SQLShellWindow; @@ -99,7 +101,7 @@ }; Command cmd = new nl.improved.sqlclient.AbstractSQLShellWindow.ExecuteBatchCommand(sqlshellWindow); - cmd.execute(new SQLCommand("@"+ argsMap.get("-i"))); + CommandResult result = cmd.execute(new SQLCommand("@"+ argsMap.get("-i"))); if (argsMap.containsKey("-o")) { File f = new File(argsMap.get("-o")); FileOutputStream fout = new FileOutputStream(f); @@ -107,8 +109,16 @@ fout.write(s.toString().getBytes()); fout.write('\n'); } - //fout.write(output.toString().getBytes()); - //fout.write('\n'); + Iterator<CharSequence> iResult = result.getResult(); + while (iResult.hasNext()) { + fout.write(iResult.next().toString().getBytes()); + } + fout.write('\n'); + } else { + Iterator<CharSequence> iResult = result.getResult(); + while (iResult.hasNext()) { + System.out.println(iResult.next()); + } } } else { //sqlshellWindow = new SQLShellWindow(); |
From: SVN by r. <sv...@ca...> - 2009-01-17 15:11:48
|
Author: roy Date: 2009-01-17 16:11:40 +0100 (Sat, 17 Jan 2009) New Revision: 354 Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java Log: added more help and fixed existing help for batchcommand added options to abort on error in execute batch command Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-01-17 14:55:32 UTC (rev 353) +++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-01-17 15:11:40 UTC (rev 354) @@ -2086,7 +2086,9 @@ SQLCommand sqlCmd = new SQLCommand(); String line; int errorCount = 0; - while ( ((line = reader.readLine()) != null)) { + boolean continueOnError = true; + boolean abortedOnError = false; + while ( !abortedOnError && ((line = reader.readLine()) != null)) { if (cancelled) { return new SimpleCommandResult(true, "Aborted"); } @@ -2095,6 +2097,16 @@ } sqlCmd.getEditableLines().add(new StringBuffer(line)); String commandString = sqlCmd.getUntrimmedCommandString(); + if (commandString.matches("@@continue_on_error.*")) { + continueOnError = true; + sqlCmd = new SQLCommand(); + continue; + } + if (commandString.matches("@@abort_on_error.*")) { + continueOnError = false; + sqlCmd = new SQLCommand(); + continue; + } currentCommand = sqlShell.createCommand(commandString); if (currentCommand == null) { continue; @@ -2110,10 +2122,16 @@ } if (!result.executedSuccessfully()) { errorCount++; + if (!continueOnError) { + abortedOnError = true; + } sqlShell.output("Execution Failed...\n"); } } catch(Exception e) { errorCount++; + if (!continueOnError) { + abortedOnError = true; + } sqlShell.error(e); } sqlCmd=new SQLCommand(); @@ -2124,6 +2142,10 @@ } }.start(); } + if (abortedOnError) { + return new SimpleCommandResult(false, "Execution of file '" + toFileName(command.substring(1)) +"' aborted because of an error in statement '"+ + sqlCmd.getUntrimmedCommandString()+"'...."); + } if (cancelled) { return new SimpleCommandResult(true, "Execution of file '" + toFileName(command.substring(1)) +"' aborted...."); } @@ -2160,9 +2182,15 @@ @Override public CharSequence getHelp() { return "Specify filename to execute a 'batch' command.\n"+ - "For example '@mystatements.sql' executes all statements part of the mystatements.sql file in the current directory."+ - "Note that all statements must be terminated with ';' (sql statements as well as connect statements or spool)"; + "For example '@mystatements.sql' executes all statements part of the mystatements.sql file in the current directory.\n"+ + "Statements can include all sqlshell supported commands such as spool, dump, read as well as all supported sql statements.\n\n" + + "Aborting the command stops the execution of the batch command, however there won't be an automatic rollback of successfull update/delete statements," + + "so rollback (if supported and required) has to be called by the user.\n\n" + + "You can include commands in the batch to control behaviour on errors:\n" + + "* @@continue_on_error (this is the default behaviour)\n" + + "* @@abort_on_error"; } + @Override public boolean abort() { cancelled = true; |
From: SVN by r. <sv...@ca...> - 2009-01-17 14:55:45
|
Author: roy Date: 2009-01-17 15:55:32 +0100 (Sat, 17 Jan 2009) New Revision: 353 Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java Log: fix parsing of sqlcommands when using batch commands Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-01-16 20:58:47 UTC (rev 352) +++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-01-17 14:55:32 UTC (rev 353) @@ -2083,7 +2083,7 @@ fin = new FileInputStream(toFileName(command.substring(1))); sqlShell.output("Reading file: "+ toFileName(command.substring(1))); BufferedReader reader = new BufferedReader(new InputStreamReader(fin)); - StringBuffer cmd = new StringBuffer(); + SQLCommand sqlCmd = new SQLCommand(); String line; int errorCount = 0; while ( ((line = reader.readLine()) != null)) { @@ -2093,8 +2093,8 @@ if (line.startsWith("--")) { continue; } - cmd.append(line); - String commandString = cmd.toString(); + sqlCmd.getEditableLines().add(new StringBuffer(line)); + String commandString = sqlCmd.getUntrimmedCommandString(); currentCommand = sqlShell.createCommand(commandString); if (currentCommand == null) { continue; @@ -2116,7 +2116,7 @@ errorCount++; sqlShell.error(e); } - cmd=new StringBuffer(); + sqlCmd=new SQLCommand(); new Thread() { @Override public void run() { @@ -2127,8 +2127,8 @@ if (cancelled) { return new SimpleCommandResult(true, "Execution of file '" + toFileName(command.substring(1)) +"' aborted...."); } - if (cmd.toString().trim().length() > 0) { - return new SimpleCommandResult(false, "File '"+ toFileName(command.substring(1)) +"' missing a ';' at the end of the last command"); + if (sqlCmd.getCommandString().trim().length() > 0) { + return new SimpleCommandResult(false, "File '"+ toFileName(command.substring(1)) +"' missing a ';' at the end of the last command (" + sqlCmd.getUntrimmedCommandString()+")"); } else { return new SimpleCommandResult(true, "File '" + toFileName(command.substring(1)) +"' executed " + (errorCount > 0 ? "with "+ errorCount+" errors." : "successfully.")); } |
From: SVN by r. <sv...@ca...> - 2009-01-16 20:58:55
|
Author: roy Date: 2009-01-16 21:58:47 +0100 (Fri, 16 Jan 2009) New Revision: 352 Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java Log: error handling in batch command Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-01-16 20:44:06 UTC (rev 351) +++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2009-01-16 20:58:47 UTC (rev 352) @@ -2112,16 +2112,17 @@ errorCount++; sqlShell.output("Execution Failed...\n"); } - cmd=new StringBuffer(); - new Thread() { - @Override - public void run() { - sqlShell.repaint(); - } - }.start(); } catch(Exception e) { + errorCount++; sqlShell.error(e); } + cmd=new StringBuffer(); + new Thread() { + @Override + public void run() { + sqlShell.repaint(); + } + }.start(); } if (cancelled) { return new SimpleCommandResult(true, "Execution of file '" + toFileName(command.substring(1)) +"' aborted...."); |