Java Doc for SqlFile.java in  » Database-DBMS » hsql » org » hsqldb » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » hsql » org.hsqldb.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.hsqldb.util.SqlFile

SqlFile
public class SqlFile (Code)
Encapsulation of a sql text file like 'myscript.sql'. The ultimate goal is to run the execute() method to feed the SQL commands within the file to a jdbc connection. Some implementation comments and variable names use keywords based on the following definitions.
  • COMMAND = Statement || SpecialCommand || BufferCommand Statement = SQL statement like "SQL Statement;" SpecialCommand = Special Command like "\x arg..." BufferCommand = Editing/buffer command like ":s/this/that/" When entering SQL statements, you are always "appending" to the "immediate" command (not the "buffer", which is a different thing). All you can do to the immediate command is append new lines to it, execute it, or save it to buffer. When you are entering a buffer edit command like ":s/this/that/", your immediate command is the buffer-edit-command. The buffer is the command string that you are editing. The buffer usually contains either an exact copy of the last command executed or sent to buffer by entering a blank line, but BUFFER commands can change the contents of the buffer. In general, the special commands mirror those of Postgresql's psql, but SqlFile handles command editing much different from Postgresql because of Java's lack of support for raw tty I/O. The \p special command, in particular, is very different from psql's. Buffer commands are unique to SQLFile. The ":" commands allow you to edit the buffer and to execute the buffer. \d commands are very poorly supported for Mysql because (a) Mysql lacks most of the most basic JDBC support elements, and the most basic role and schema features, and (b) to access the Mysql data dictionay, one must change the database instance (to do that would require work to restore the original state and could have disastrous effects upon transactions). To make changes to this class less destructive to external callers, the input parameters should be moved to setters (probably JavaBean setters would be best) instead of constructor args and System Properties. The process*() methods, other than processBuffHist() ALWAYS execute on "buffer", and expect it to contain the method specific prefix (if any).
    version:
       $Revision: 1.169 $
    author:
       Blaine Simpson unsaved@users


Field Summary
public static  StringLS
    
 byte[]binBuffer
    
 StringBufferimmCmdSB
    
 intoldestHist
    
public  booleanplMode
    
 BooleanBucketpossiblyUncommitteds
    
public  booleanrecursed
    

Constructor Summary
public  SqlFile(File inFile, boolean inInteractive, Map inVars)
     Interpret lines of input file as SQL Statements, Comments, Special Commands, and Buffer Commands.
public  SqlFile(boolean inInteractive, Map inVars)
     Constructor for reading stdin instead of a file for commands.

Method Summary
public static  voidappendLine(StringBuffer sb, String s)
    
public static  booleancanDisplayType(int i)
     This method is used to tell SqlFile whether this Sql Type must ALWAYS be loaded to the binary buffer without displaying.
public static  StringconvertEscapes(String inString)
     Translates user-supplied escapes into the traditionaly corresponding corresponding binary characters.
public  voiddsvSafe(String s)
     Validate that String is safe to display in a DSV file.
public  voidexecute(Connection conn, Boolean coeOverride)
     Process all the commands on stdin.
public  voidexecute(Connection conn, boolean coeOverride)
     Process all the commands on stdin.
public synchronized  voidexecute(Connection conn, PrintStream stdIn, PrintStream errIn, Boolean coeOverride)
     Process all the commands in the file (or stdin) associated with "this" object. Run SQL in the file through the given database connection. This is synchronized so that I can use object variables to keep track of current line number, command, connection, i/o streams, etc. Sets encoding character set to that specified with System Property 'sqlfile.charset'.
public  voidimportDsv(String filePath, String skipPrefix)
     Name is self-explanatory.
public static  byte[]loadBinary(File binFile)
    
static  intpastName(String inString, int startIndex)
     Returns index specifying 1 past end of a variable name.
public  voidprocessFromBuffer()
     Execute processSql/processPL/processSpecial from buffer.
public static  StringsqlTypeToString(int i)
    
public static  byte[]streamToBytes(InputStream is)
    
public  StringstreamToString(InputStream is, String cs)
     As the name says...

Field Detail
LS
public static String LS(Code)



binBuffer
byte[] binBuffer(Code)



immCmdSB
StringBuffer immCmdSB(Code)



oldestHist
int oldestHist(Code)



plMode
public boolean plMode(Code)



possiblyUncommitteds
BooleanBucket possiblyUncommitteds(Code)



recursed
public boolean recursed(Code)




Constructor Detail
SqlFile
public SqlFile(File inFile, boolean inInteractive, Map inVars) throws IOException(Code)
Interpret lines of input file as SQL Statements, Comments, Special Commands, and Buffer Commands. Most Special Commands and many Buffer commands are only for interactive use.
Parameters:
  inFile - inFile of null means to read stdin.
Parameters:
  inInteractive - If true, prompts are printed, the interactiveSpecial commands are enabled, andcontinueOnError defaults to true.
throws:
  IOException - If can't open specified SQL file.



SqlFile
public SqlFile(boolean inInteractive, Map inVars) throws IOException(Code)
Constructor for reading stdin instead of a file for commands.
See Also:   SqlFile.SqlFile(File,boolean)




Method Detail
appendLine
public static void appendLine(StringBuffer sb, String s)(Code)



canDisplayType
public static boolean canDisplayType(int i)(Code)
This method is used to tell SqlFile whether this Sql Type must ALWAYS be loaded to the binary buffer without displaying. N.b.: If this returns "true" for a type, then the user can never "see" values for these columns. Therefore, if a type may-or-may-not-be displayable, better to return false here and let the user choose. In general, if there is a toString() operator for this Sql Type then return false, since the JDBC driver should know how to make the value displayable. The table on this page lists the most common SqlTypes, all of which must implement toString(): http://java.sun.com/docs/books/tutorial/jdbc/basics/retrieving.html
See Also:   java.sql.Types



convertEscapes
public static String convertEscapes(String inString)(Code)
Translates user-supplied escapes into the traditionaly corresponding corresponding binary characters. Allowed sequences:
  • \0\d+ (an octal digit)
  • \[0-9]\d* (a decimal digit)
  • \[Xx][0-9]{2} (a hex digit)
  • \n Newline (Ctrl-J)
  • \r Carriage return (Ctrl-M)
  • \t Horizontal tab (Ctrl-I)
  • \f Form feed (Ctrl-L)
Java 1.4 String methods will make this into a 1 or 2 line task.



dsvSafe
public void dsvSafe(String s) throws SqlToolError(Code)
Validate that String is safe to display in a DSV file.
throws:
  SqlToolError - if validation fails.



execute
public void execute(Connection conn, Boolean coeOverride) throws SqlToolError, SQLException(Code)
Process all the commands on stdin.
Parameters:
  conn - The JDBC connection to use for SQL Commands.
See Also:   SqlFile.execute(Connection,PrintStream,PrintStream,boolean)



execute
public void execute(Connection conn, boolean coeOverride) throws SqlToolError, SQLException(Code)
Process all the commands on stdin.
Parameters:
  conn - The JDBC connection to use for SQL Commands.
See Also:   SqlFile.execute(Connection,PrintStream,PrintStream,boolean)



execute
public synchronized void execute(Connection conn, PrintStream stdIn, PrintStream errIn, Boolean coeOverride) throws SqlToolError, SQLException(Code)
Process all the commands in the file (or stdin) associated with "this" object. Run SQL in the file through the given database connection. This is synchronized so that I can use object variables to keep track of current line number, command, connection, i/o streams, etc. Sets encoding character set to that specified with System Property 'sqlfile.charset'. Defaults to "US-ASCII".
Parameters:
  conn - The JDBC connection to use for SQL Commands.
throws:
  SQLExceptions - thrown by JDBC driver.Only possible if in "\c false" mode.
throws:
  SqlToolError - all other errors.This includes including QuitNow, BreakException,ContinueException for recursive calls only.



importDsv
public void importDsv(String filePath, String skipPrefix) throws SqlToolError(Code)
Name is self-explanatory. If there is user demand, open file in random access mode so don't need to load 2 copies of the entire file into memory. This will be difficult because can't use standard Java language features to search through a character array for multi-character substrings.
throws:
  SqlToolError - Would prefer to throw an internal exception,but we want this method to have externalvisibility.



loadBinary
public static byte[] loadBinary(File binFile) throws IOException(Code)
Binary file load



pastName
static int pastName(String inString, int startIndex)(Code)
Returns index specifying 1 past end of a variable name.
Parameters:
  inString - String containing a variable name
Parameters:
  startIndex - Index within inString where the variable name begins



processFromBuffer
public void processFromBuffer() throws BadSpecial, SQLException, SqlToolError(Code)
Execute processSql/processPL/processSpecial from buffer.



sqlTypeToString
public static String sqlTypeToString(int i)(Code)



streamToBytes
public static byte[] streamToBytes(InputStream is) throws IOException(Code)



streamToString
public String streamToString(InputStream is, String cs) throws IOException(Code)
As the name says... This method always closes the input stream.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.