net.directj.jlogger
Class JDBCOutput

java.lang.Object
  |
  +--net.directj.jlogger.JDBCOutput
All Implemented Interfaces:
Output

public class JDBCOutput
extends java.lang.Object
implements Output

This is a simple class that print logging information into a specified DataBase. You have to specify the Driver to use to connect the DB. Moreover, each information is numeroted, in order of arrival. This class is about to be modified in future release.

Version:
0.1.2
Author:
CARTAPANIS Alexandre <earendil@jprolog.net>

Field Summary
private  java.lang.String dbName
          The table name.
private  java.lang.String dbPass
          The user password.
private  java.lang.String dbURL
          The database URL.
private  java.lang.String dbUser
          The user name.
private  java.sql.PreparedStatement insertLog
          The SQL statement used to insert a log.
private  int num
          The current rank of inserted data.
 
Constructor Summary
JDBCOutput(java.lang.String _dbURL, java.lang.String _driverName, java.lang.String _dbName, java.lang.String _dbUser, java.lang.String _dbPass, boolean _create)
          Creates a new JDBCOutput.
 
Method Summary
 boolean equals(java.lang.Object _obj)
          Indicates whether some other object is "equal to" this one.
 int hashCode()
          Returns a hash code value for the object.
 void print(java.lang.String _str)
          Prints the info, using the output.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbURL

private java.lang.String dbURL
The database URL.


dbName

private java.lang.String dbName
The table name.


dbUser

private java.lang.String dbUser
The user name.


dbPass

private java.lang.String dbPass
The user password.


insertLog

private java.sql.PreparedStatement insertLog
The SQL statement used to insert a log.


num

private int num
The current rank of inserted data.

Constructor Detail

JDBCOutput

public JDBCOutput(java.lang.String _dbURL,
                  java.lang.String _driverName,
                  java.lang.String _dbName,
                  java.lang.String _dbUser,
                  java.lang.String _dbPass,
                  boolean _create)
Creates a new JDBCOutput. Actually, if you try to use an older table (param _create false), the table must have a special format (the SQL request is 'num INT NOT NULL PRIMARY KEY, type VARCHAR(50) NOT NULL, from VARCHAR(50) NOT NULL, at VARCHAR(50) NOT NULL, message VARCHAR(255) NOT NULL'). There is two reason of possible error: The table does not respect the above structure, or the table is not empty and the 'num' variable can be in double (that is not allowed because of it's the primary key). This implementation is about to be modified in future release.

Parameters:
_dbURL - The database url, like 'jdbc:odbc:database'.
_driverName - The name of the class that will be loaded as the DB driver, like 'sun.jdbc.odbc.JdbcOdbcDriver'.
_dbName - The name of the table, in the _dbURL DB.
_dbUser - The user name to access the DB.
_dbPass - The user password to access the DB.
_create - Indicate if we create a new table or use an existing one.
Method Detail

print

public void print(java.lang.String _str)
Prints the info, using the output. There is two reason of possible error: The table does not respect the above structure, or the table is not empty and the 'num' variable can be in double (that is not allowed because of it's the primary key). This implementation is about to be modified in future release. WARNING: The string must use the 'type|name|time|message' pattern.

Specified by:
print in interface Output
Parameters:
_str - The debugging info to print on the output.
See Also:
Formatter

equals

public boolean equals(java.lang.Object _obj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class java.lang.Object
Parameters:
_obj - The reference object with which to compare.
Returns:
boolean - True if this object is the same as the obj argument; false otherwise.

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

Overrides:
hashCode in class java.lang.Object
Returns:
int - A hash code value for this object.


Copyright 2002 CARTAPANIS Alexandre
This page was last updated on May 10 2003