Fredy's Admin Tool ------------------ Admin is a Tool around JDBC-enabled SQL-Databases to do basic jobs for DB-Administrations, like: - create/ drop tables - create indices - perform sql-statements - simple form - a guided query - Data Export and a other usefull things in DB-arena License: -------- Admin is under LGPL. Copyright (C) 1999 Fredy Fischer sql at hulmen dot ch www.hulmen.ch Fredy Fischer Hulmenweg 36 8405 Winterthur Switzerland This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Structure --------- Admin consists out of two parts: 1) The Admin Tool 2) Application Part Admin Tool ---------- Admin is heavily based onto MetaData of a database. If these data are not available or not complete, not all functions of Admin will work. Admin is divided into these packages: gpl.fredy.admin the main Class of the Project gpl.fredy.share a part containing classes needed by all packages. These are some classes hardly to sort different gpl.fredy.tools contains the Logserver I wrote. SimpleLogServer and all its related classes gpl.fredy.io contains all classes I need to handle IO-related questions gpl.fredy.sqltools all the tools needed form DDL and DML gpl.fredy.metadata these are the classes used to collect metadata information gpl.fredy.ui some user interface related classes gpl.fredy.generate the classes I use to generate Java-Code Applications Part ----------------- This you only need, if you intend to generate Java-Code out of Admin. Admin has a function, that creates Java-Code out of a table. It does the following classes for each table of a certain database: a)the wrapper file: The name of that class is Row.java .This code contains for each field in the table a get and a set methode. As well as there are insert, update, save and delete methods and searchBy{Fieldname}-methods. As well as there is a searchAll-method. These searchXXX-methods are of type xxxRow. All searchBy{FieldName}-mathods are as follows: public String searchBy(String,boolean) Where String is the searchpattern and the boolean is to do a search as follows: true = exact search (e.g. search * from table where field = false= use wildcards (e.g. search * from table where field like b)the Swing-GUI The name of that class is Form.java. This is a simple swing-class delivering a gui, as you see it in the screenshots. You can launch this application equal you are launching admin. There is an example, where you see how I did it. It is basically: java -Duser.home={userhome} applications.{DB-Name}.{TableName}Formd -h host -u user -p password c)the JTableModel The name of this class is TableModel.java. IT allows to write back values to the DB as they are changed, if the primarykey is known. These files you best save into the directory ./java/applications. Admin then creates a directory named like the DB-name where it puts all these files into. See the documentation codegenerator.pdf for further information. Prerequisits ------------ Minimum: * java in version 1.5 and higher (http://java.sun.com) * a JDBC-Driver for your RDBMS Data Exporter: DataExporter exports data into CSV, XML and XLS, if you want to have XLS-files, you need to add POI to your CLASSPATH * POI from http://jakarta.apache.org/poi Code Generator * JDOM minimum Beta 8 (http://www.jdom.org) * CalendarBean.jar (http://www.toedter.com/en/jcalendar/index.html) developed by Kai Toedter * MSeries by Martin Newstead (http://web.ukonline.co.uk/mseries/downloads.html) Look-n-feel * kunststoff.jar * nextlf.jar I put some of these JARS into the directory jars. Copyrights and license schemas of theses jars apply. Install ------- 1) Create your directory ADMIN_HOME and install all the files there. So there will be this structure: ADMIN_HOME/gpl/fredy/admin share tools io sqltools ui generate metadata ADMIN_HOME/applictions/basics 2) Add ADMIN_HOME and all the archives you need to your classpath 3) make sure, your PATH-Variable points to the right JDK/JRE min. 1.4 Starting Admin -------------- Make sure to have the CLASSPATH fine, what means add in minimum the follwing to your CLASSPATH; - the topdirectory, where you extracted Admin in -> ADMIN_HOME - you need to have your RDBMS-JDBC-Driver within your CLASSPATH - I've put all the jars I personally have in my CLASSPATH to use Admin here http://www.hulmen.ch/admin/jars java gpl.fredy.admin.Admin This launches Admin with the standard values. Admin creates to property files: - admin.props - t_connect.props These files are stored by default in the users home directory. You can change this behaviour like this: change the user.home property of java: java -Duser.home=MYDIRECTORY gpl.fredy.admin.Admin or java -Dadmin.work=MYDIRECTORY gpl.fredy.admin.Admin Admin needs a number of icons to display. By default these icons are in ADMIN_HOME/gpl/fredy/images. You can change this behaviour like this: java -Dadmin.image=MYIMAGEDIRECTORY gpl.fredy.admin.Admin Admin searches in the file ADMIN_HOME/gpl/fredy/share/rdbms.dat predefined connections. Probably your RDBMS is already there, if not, open this file with your preferred editor and add your RDBMS. Please let me know it, so we can extend the list of the 'tested-with'. Logging ------- Admin uses java.util.logging for logging. You can change the behaviour of this logger by editing JAVA_HOME/jre/lib/logging.properties according your needs. I also wrote a simple tools to collect logging-information, SimpleLogServer. SimpleLogServer (SLS) is listening onto a TCP-Port (default 5237) and receives logrecords formatted by the FxmlFormatter and is able to display these in a GUI. If you want to use this functionality, proceed as follows: Configure the JAVA_HOME/jre/lib/logging.properties to be a File and/or console- logger. Start SLS as this: java gpl.fredy.tools.SimpleLogServer -GUI [-p PORT] So SLS is listening onto port 5237 and is ready to receive logrecords. The reason not to change the generic logging.properties-file is because of avoiding loops. Now you start Admin like this: java -Djava.util.logging.config.file=ADMIN_HOME/gpl/fredy/admin/logging.properties gpl.fredy.Admin Compilation ----------- I did not find the time to dig into ant. So please compile as follows: 1) gpl.fredy.share 2) gpl.fredy.metadata 3) gpl.fredy.ui 4) gpl.fredy.sqltools 5) gpl.fredy.generate 6) gpl.fredy.admin MySQL ----- I mostly use MySQL to develop Admin. For testpurpose I created a little dashboard for MySQL you might be interested in. If you connect to MySQL with Admin, you will find a MenuItem DashBoard under tools. You also can launch this Dashboard manually: java gpl.fredy.ui.MySQLconnections host user password database History ------- In the beginnings of Java I had my first look at this exciting product. So I decided to learn more about Java. As beeing a developer for data -base-applications and generator in my former life it was a short decision to use a database related case for learning Java. So I started 1997 the development of a tool to manipulate mySQL-Datatabass. As JDBC (Java Database Connectivity) supports a lot of functions around metadata, it was a good starting point for learning Java. When Swing came out the GUI-capabilities of Java got much more functionalities. So I choosed Swing as the GUI-representation of my new tool. The first steps with Java where pretty hard for a procedural software developper I was of about then years, but thanks to the help of some friends I got my first impression of how object oriented programming probably looks like and was able to implement the first function. To really get on speed I did not choose a 'Hello World' thing, I directly jumped into the development of the 'Guided-Query'-class. While doing so, I had to learn how Java handels Meta-Data and how these layout-managers works to create my first Swing-GUI. While time was passing by, Admin got more and more functions and thanks to the JDBC-concept it was able to support other databases. Today I did some tests with mySQL, PostgreSQL, InstantDB, HypersonicSQL, Oracle and Empress. As the intention of the project is to learn about Java I put it under open-source. To publish this tool I became a member of the organization trash.net . Admin is absolutely free for download and use. Admin offers today the following functions: * Create Table * Create Index * Drop Table * Modify Table * Guided Query * SQL-Monitor * Dynamic online form * Generate Java Code out of a XML-File (a Relational-Object-Wrapper and a Swing-Form and a JTableModel) * Meta-Data Info of a DB * DataExport into various formats All the windows are generated as panels, so they are able to run as standalone also Such a tool is an ongoing project and probably I get some input from you. Today Admin has been downloaded several thousand times and I got a lot of contacts to the internet-community from allover the world. I'd be happy if you have a look at the product and to get some response and ideas to make the tool more powerfull.