FreenetWiki : ThawHsqldbIntegration

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register
Most recent edit on 2008-02-19 17:28:11 by JeromeFlesch [meh]

Additions:
To access to the Hsql database of Thaw from a plugin, you need to pass by the Hsqldb plugin. Here is a basic example for a plugin using hsqldb in thaw:

Deletions:
To access to the Hsql database of Thaw from a plugin, you need to pass by the Hsqldb plugin. Here is a sample:



Edited on 2007-04-11 15:21:12 by JeromeFlesch

Additions:
Regarding the methods registerChild() and unregisterChild(), you can look at the thaw.core.LibraryPlugin javadoc for more details.

Deletions:
Regarding the methods registerChild() and unregisterChild(), you can look at thaw.core.LibraryPlugin javadoc for more details.



Edited on 2007-01-15 07:08:35 by JeromeFlesch

Deletions:
NB: This console is slow: Don't make query with too much results.



Edited on 2006-11-30 13:09:13 by JeromeFlesch

Additions:
NB: This console is slow: Don't make query with too much results.



Edited on 2006-08-12 23:30:18 by JeromeFlesch

Additions:
Homepage



Edited on 2006-08-06 20:01:34 by JeromeFlesch

Additions:
|| !core.getPluginManager().runPlugin("thaw.plugins.Hsqldb")) { /* Hsqldb.run() do almost nothing, see Hsqldb.registerChild() */

Deletions:
|| !core.getPluginManager().runPlugin("thaw.plugins.Hsqldb")) { /* Hsqldb.run() do almost nothing, see Hsqldb.registerChilld() */



Edited on 2006-08-06 20:00:38 by JeromeFlesch

Deletions:
private IndexEditorPanel editorPanel;
private JPanel panel;



Edited on 2006-08-06 19:58:07 by JeromeFlesch

No differences.


Edited on 2006-08-06 17:10:11 by JeromeFlesch

Additions:
~- "drop_tables" => Drop all the tables used for the indexations.

Deletions:
~- "drop_tables" => Drop all the tables.



Edited on 2006-08-06 17:07:02 by JeromeFlesch

Additions:
Shortcut available:
  • "list_tables" => "SELECT * FROM INFORMATION_SCHEMA.SYSTEM_TABLES"
  • "drop_tables" => Drop all the tables.

    Deletions:
    There is shortcut available: "list_tables" => "SELECT * FROM INFORMATION_SCHEMA.SYSTEM_TABLES"



    Edited on 2006-08-06 15:32:04 by JeromeFlesch

    Additions:

    Plugins using Hsqldb

  • SQL Console

    You can access yourself to the database by using the Thaw SQL Console:
    Put Thaw in advanced mode, and load the plugin "thaw.plugins.SqlConsole".
    The SQL used is, of course, the Hsqldb one :)
    There is shortcut available: "list_tables" => "SELECT * FROM INFORMATION_SCHEMA.SYSTEM_TABLES"




    Edited on 2006-08-06 12:40:03 by JeromeFlesch

    Additions:
    /* ADD YOUR CODE HERE */

    Deletions:
    /* ADD HERE YOUR CODE */



    Edited on 2006-08-06 12:29:29 by JeromeFlesch

    Additions:
    Regarding the methods registerChild() and unregisterChild(), you can look at thaw.core.LibraryPlugin javadoc for more details.



    Edited on 2006-08-06 12:28:10 by JeromeFlesch

    Additions:
    it has. When this number reach 0, then it can disconnect from the database.

    Deletions:
    it has. When this number reach 0, then it can disconnect from the database.



    Edited on 2006-08-06 12:27:58 by JeromeFlesch

    Additions:
    /* We need to register: Like this, Hsqldb plugin can know how many child plugins
    it has. When this number reach 0, then it can disconnect from the database.
    */

    Deletions:
    /* We need to register: Like this, Hsqldb plugin can know how many child plugins
    it has. When this number reach 0, then it can disconnect from the database.
    */




    Edited on 2006-08-06 12:27:49 by JeromeFlesch

    Additions:
    /* We need to register: Like this, Hsqldb plugin can know how many child plugins
    it has. When this number reach 0, then it can disconnect from the database.
    */


    Deletions:
    /* We need to register: Like this, Hsqldb plugin can know how many child plugins
    it has. When this number reach 0, then it can disconnect from the database.
    */




    Edited on 2006-08-06 12:27:33 by JeromeFlesch

    Additions:
    /* If Hsqldb plugin is not already loaded, then we need to load it */

    Deletions:
    /* If Hsqldb plugin is not already loaded, then we need to load it */



    Edited on 2006-08-06 12:27:22 by JeromeFlesch

    Additions:
    /* If Hsqldb plugin is not already loaded, then we need to load it */

    Deletions:
    /* If Hsqldb plugin is not already loaded, then we need to load it */



    Edited on 2006-08-06 12:26:56 by JeromeFlesch

    Additions:
    %%(java)

    Deletions:
    %%(Java)



    Oldest known version of this page was edited on 2006-08-06 12:26:31 by JeromeFlesch []
    Page view:

    Thaw Hsqldb Integration


    To access to the Hsql database of Thaw from a plugin, you need to pass by the Hsqldb plugin. Here is a sample:

    package thaw.plugins;
    
    import java.sql.*;
    
    import thaw.core.*;
    
    public class PluginUsingHsqldb implements Plugin {
    	private Core core;
    	private Hsqldb hsqldb;
    
    	private IndexEditorPanel editorPanel;
    	private JPanel panel;
    
    	public PluginUsingHsqldb() {
    	        /* never called */
    	}
    
    	public boolean run(Core core) {
    		this.core = core;
    
    	            /* If Hsqldb plugin is not already loaded, then we need to load it */
    		if(core.getPluginManager().getPlugin("thaw.plugins.Hsqldb") == null) {
    			Logger.info(this, "Loading Hsqldb plugin");
    
    			if(!core.getPluginManager().loadPlugin("thaw.plugins.Hsqldb")
    			   || !core.getPluginManager().runPlugin("thaw.plugins.Hsqldb")) { /* Hsqldb.run() do almost nothing, see Hsqldb.registerChilld() */
    				Logger.error(this, "Unable to load thaw.plugins.Hsqldb !");
    				return false;
    			}
    		}
    
    		hsqldb = (Hsqldb)core.getPluginManager().getPlugin("thaw.plugins.Hsqldb");
    
    	            /* We need to register: Like this, Hsqldb plugin can know how many child plugins
    	               it has. When this number reach 0, then it can disconnect from the database.
    	             */
    		hsqldb.registerChild(this);
    
    
    	            /* ADD HERE YOUR CODE */
    
    		return true;
    	}
    
    
    	public boolean stop() {
    		hsqldb.unregisterChild(this);
    		return true;
    	}
    
    	public String getNameForUser() {
    		return I18n.getMessage("thaw.plugin.PluginUsingHsqldb");
    	}
    }


    When you have a reference to the Hsqldb plugin, then you can use getConnection() or executeQuery() or execute() to send query to the database (but be careful about the SQL Exception).
    From this point, everything works as usual with Jdbc.
    Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.2
    Page was generated in 0.1342 seconds