Class SqlFileEmbedder


  • public class SqlFileEmbedder
    extends java.lang.Object
    Sample class which executes SQL files, by embedding SqlFile.

    Suitable for using as a template.

    This class also serves as an example of using RCData to allow your application users to store JDBC access information in a convenient text file.

    Author:
    Blaine Simpson (blaine dot simpson at admc dot com)
    See Also:
    main(String[]), SqlFile, RCData
    • Constructor Summary

      Constructors 
      Constructor Description
      SqlFileEmbedder​(java.io.File rcFile, java.lang.String urlid)
      Instantiates SqlFileEmbedder object and connects to specified database.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void executeFiles​(java.lang.String[] fileStrings)
      Your own classes can use this method to execute SQL files.
      java.sql.Connection getConn()
      For applications that use a persistent JDBC connection, this class can be used to encapsulate that connection.
      static void main​(java.lang.String[] sa)
      Run
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SqlFileEmbedder

        public SqlFileEmbedder​(java.io.File rcFile,
                               java.lang.String urlid)
                        throws java.lang.Exception
        Instantiates SqlFileEmbedder object and connects to specified database.

        N.b., you do not need to use RCData to use SqlFile. All SqlFile needs is a live Connection. I'm using RCData because it is a convenient way for a non-contained app (i.e. one that doesn't run in a 3rd party container) to get a Connection.

        Throws:
        java.lang.Exception
    • Method Detail

      • getConn

        public java.sql.Connection getConn()
        For applications that use a persistent JDBC connection, this class can be used to encapsulate that connection. (Just strip out the SqlFile stuff if you don't need that).
        Returns:
        The encapsulated JDBC Connection.
      • main

        public static void main​(java.lang.String[] sa)
                         throws java.lang.Exception
        Run
             java SqlFileEmbedder
        to see Syntax message.
        Throws:
        java.lang.Exception
      • executeFiles

        public void executeFiles​(java.lang.String[] fileStrings)
                          throws java.io.IOException,
                                 org.hsqldb.cmdline.SqlToolError,
                                 java.sql.SQLException
        Your own classes can use this method to execute SQL files.

        See source code for the main(String[]) method for an example of calling this method.

        Throws:
        java.io.IOException
        org.hsqldb.cmdline.SqlToolError
        java.sql.SQLException
        See Also:
        main(String[])