org.objectweb.cjdbc.console.text.module
Class VirtualDatabaseConsole

java.lang.Object
  extended byorg.objectweb.cjdbc.console.text.module.AbstractConsoleModule
      extended byorg.objectweb.cjdbc.console.text.module.VirtualDatabaseConsole

public class VirtualDatabaseConsole
extends AbstractConsoleModule

C-JDBC Controller Virtual Database Console module.

Version:
1.0
Author:
Emmanuel Cecchet , Mathieu Peltier , Nicolas Modrzyk

Field Summary
private  java.sql.Connection connection
           
private  int fetchsize
           
private  java.lang.String login
           
private static int MAX_COLUMN_DISPLAY_WIDTH
          Max column width when displaying a ResultSet.
private  int maxrows
           
private  int timeout
          Default query timeout.
private  java.lang.String url
           
 
Fields inherited from class org.objectweb.cjdbc.console.text.module.AbstractConsoleModule
commands, console, history, quit
 
Constructor Summary
VirtualDatabaseConsole(Console console)
          Creates a new VirtualDatabaseAdmin instance.
 
Method Summary
 void callStoredProcedure(java.lang.String proc, boolean displayResult)
          Call a store procedure.
private  void displayPad(java.lang.String text, int size)
           
 void displayResultSet(java.sql.ResultSet rs)
          Display the given ResultSet.
private  void displaySeparatorLine(int columnCount, java.sql.ResultSetMetaData meta)
           
 void execSQL(java.lang.String request, boolean displayResult)
          Executes a SQL statement.
 java.sql.Connection getConnection(java.lang.String url, java.lang.String login, java.lang.String password)
          Gets a new connection from the driver.
 java.lang.String getDescriptionString()
          Text description of this module
 java.lang.String getPromptString()
          Get the prompt string for this module
 void handlePrompt()
          Connects to a virtual database.
 void help()
          Displays help message.
 void load(java.lang.String fileName)
          Executes all the SQL requests contained in the specified file.
protected  void loadCommands()
          Loads the commands for this module
 void login(java.lang.String[] params)
          Handles login in this module
 void quit()
          Quit this module
 void showtables()
          Display all tables of this virtual database
 
Methods inherited from class org.objectweb.cjdbc.console.text.module.AbstractConsoleModule
getCommands, getConsole, getHashCommands, getHistory, handleCommandLine, loadCompletor, manageHistory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_COLUMN_DISPLAY_WIDTH

private static final int MAX_COLUMN_DISPLAY_WIDTH
Max column width when displaying a ResultSet.

See Also:
Constant Field Values

connection

private java.sql.Connection connection

timeout

private int timeout
Default query timeout.


fetchsize

private int fetchsize

maxrows

private int maxrows

login

private java.lang.String login

url

private java.lang.String url
Constructor Detail

VirtualDatabaseConsole

public VirtualDatabaseConsole(Console console)
Creates a new VirtualDatabaseAdmin instance. Loads the driver

Parameters:
console - console console
Method Detail

getConnection

public java.sql.Connection getConnection(java.lang.String url,
                                         java.lang.String login,
                                         java.lang.String password)
                                  throws ConsoleException
Gets a new connection from the driver.

Parameters:
url - the C-JDBC url
login - the login to use to open the connection
password - the password to use to open the connection
Returns:
a new connection
Throws:
ConsoleException - if login failed

displaySeparatorLine

private void displaySeparatorLine(int columnCount,
                                  java.sql.ResultSetMetaData meta)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

displayPad

private void displayPad(java.lang.String text,
                        int size)

displayResultSet

public void displayResultSet(java.sql.ResultSet rs)
                      throws java.sql.SQLException
Display the given ResultSet.

Parameters:
rs - the ResultSet to display
Throws:
java.sql.SQLException - if an error occurs

callStoredProcedure

public void callStoredProcedure(java.lang.String proc,
                                boolean displayResult)
Call a store procedure.

Parameters:
proc - the stored procedure to call
displayResult - true if the result must be printed on the standard output

execSQL

public void execSQL(java.lang.String request,
                    boolean displayResult)
Executes a SQL statement.

Parameters:
request - the SQL request to execute
displayResult - true if the result must be printed on the standard output

showtables

public void showtables()
Display all tables of this virtual database


load

public void load(java.lang.String fileName)
Executes all the SQL requests contained in the specified file.

Parameters:
fileName - the file name to open

help

public void help()
Displays help message.

Overrides:
help in class AbstractConsoleModule

handlePrompt

public void handlePrompt()
Connects to a virtual database.

Overrides:
handlePrompt in class AbstractConsoleModule

getDescriptionString

public java.lang.String getDescriptionString()
Description copied from class: AbstractConsoleModule
Text description of this module

Specified by:
getDescriptionString in class AbstractConsoleModule
Returns:
String description to display
See Also:
AbstractConsoleModule.getDescriptionString()

getPromptString

public java.lang.String getPromptString()
Description copied from class: AbstractConsoleModule
Get the prompt string for this module

Specified by:
getPromptString in class AbstractConsoleModule
Returns:
String to place before prompt
See Also:
AbstractConsoleModule.getPromptString()

loadCommands

protected void loadCommands()
Description copied from class: AbstractConsoleModule
Loads the commands for this module

Specified by:
loadCommands in class AbstractConsoleModule
See Also:
AbstractConsoleModule.loadCommands()

login

public void login(java.lang.String[] params)
           throws java.lang.Exception
Description copied from class: AbstractConsoleModule
Handles login in this module

Specified by:
login in class AbstractConsoleModule
Parameters:
params - parameters to use to login in this module
Throws:
java.lang.Exception - if fails
See Also:
AbstractConsoleModule.login(java.lang.String[])

quit

public void quit()
Description copied from class: AbstractConsoleModule
Quit this module

Overrides:
quit in class AbstractConsoleModule
See Also:
AbstractConsoleModule.quit()


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.