Using ij
Page 4 of 4

Getting Started with ij

Connecting to a Cloudscape Database

To connect to a Cloudscape database, you need to perform two steps:

  • Load the appropriate driver.
  • Provide a database connection URL for the database.

In ij, there are three basic ways of accomplishing these steps:

  • Full database connection URL

    ij can work with any JDBC driver. For drivers supplied by other vendors, you need to load the driver separately. For drivers supplied by Cloudscape, you can load the driver implicitly, by specifying the full database connection URL in the connection. You do not need to load the driver explicitly in a second step.

    To connect, specify the full database connection URL in a Connect command, ij.connection.connectionName property, or ij.database property.

    The database connection URL's protocol must corresponds to one of the three drivers provided by Cloudscape (see Database Connection URLs).

D:>java COM.cloudscape.tools.ij
ij version 3.6 (c) 1997-2000 Informix Software, Inc.
ij> connect 'jdbc:cloudscape:toursDB';
ij>
ij> connect 'jdbc:cloudscape:rmi://localhost:1099/toursDB';
ij(CONNECTION1)>
D:>java -Dij.connection.tdb=jdbc:cloudscape:weblogic://localhost:7001 toursDB COM.cloudscape.tools.ij ij version 3.6 (c) 1997-2000 Informix Software, Inc. TDB* - jdbc:cloudscape:toursDB * = current connection ij> D:>java -Dij.database=jdbc:cloudscape:weblogic:toursDB COM.cloudscape.tools.ij ij version 3.6 (c) 1997-2000 Informix Software, Inc. CONNECTION0* - jdbc:cloudscape:toursDB * = current connection ij> ij> connect 'jdbc:cloudscape:c:/cloudscape/demo/databases/toursDB'; ij(CONNECTION1)>
  • Protocol and short database connection URL

    For drivers supplied by Cloudscape, specifying a protocol automatically loads the appropriate driver. You do not need to load the driver explicitly in a separate step. You specify a protocol with a property ( ij.protocol or ij.protocol.protocolName) or command ( Protocol).

    To connect, specify the "short form" of the database connection URL in a Connect command, ij.connection.connectionName property, or ij.database property. A short form of the database connection URL eliminates the protocol (see About Protocols).


D:>java COM.cloudscape.tools.ij
ij version 3.6 (c) 1997-2000 Informix Software, Inc.
ij> protocol 'jdbc:cloudscape:';
ij> connect 'toursDB';
ij>
java -Dij.protocol=jdbc:cloudscape:weblogic: COM.cloudscape.tools.ij ij> connect 'newDB2;create=true'; ij> java -Dij.protocol.wlp=jdbc:cloudscape:weblogic: COM.cloudscape.tools.ij ij> connect 'newDB3;create=true' protocol wlp; ij> java -Dij.protocol=jdbc:cloudscape:rmi://localhost:1099/ COM.cloudscape.tools.ij ij> connect 'toursDB'; D:>java -Dij.protocol.myprotocolName=jdbc:cloudscape:rmi://localhost:1099/ jdbc:cloudscape: COM.cloudscape.tools.ij ij version 3.0 (c) 1997-2000 Informix Software, Inc. ij> connect 'toursDB' protocol myprotocolName; ij>
  • Driver and full database connection URL

    You can also load the driver explicitly with an ij property ( ij.driver), a system property (jdbc.drivers), or a command ( Driver).

    If you are using one of the Cloudscape-supplied drivers, use the driver names listed in Drivers.

    When using ij with another driver, use the appropriate driver.

    To connect, specify the full database connection URL in a Connect command, ij.connection.connectionName property, or ij.database property.

D:>java COM.cloudscape.tools.ij
ij version 3.6 (c) 1997-2000 Informix Software, Inc.
ij> driver 'sun.jdbc.odbc.JdbcOdbcDriver';
ij> connect 'myOdbcDataSource';
ij>

Table 3-1, "Specifying the Driver Name and database connection URL", summarizes the different ways to specify the driver name and database connection URL.

Table 3-1 Specifying the Driver Name and database connection URL

Action

System Property

ij Property

ij Command

loading the driver implicitly


ij.connection.connectionName
(plus full URL)

ij.database
(plus full URL)

ij.protocol

ij.protocol.protocolName
(plus protocol clause in Connect command)

Protocol

Connect
(plus full URL)

loading the driver explicitly

jdbc.drivers

-D ij.driver

Driver

specifying the database connection URL


ij.connection.connectionName

ij.database

Connect

ij and Servers

You can use ij as a client application that interacts with Cloudscape running in a server framework. To do that, simply load the appropriate driver and use the appropriate protocol for the server framework, either RmiJdbc or Cloudconnector.

To see what driver you need for the server framework, see Drivers.

To see what protocol you need for the server framework, see Database Connection URLs.

For examples of doing this with either framework, see the previous section, Connecting to a Cloudscape Database. This section contains numerous examples of doing that.

Using ij Commands

ij accepts a number of different commands that let you execute SQL statements or run scripts. Each ij statement must end with a semicolon.

For complete information about ij commands, see ij Commands and Errors Reference.

Other Uses for ij

ij is a JDBC-neutral scripting tool with a small command set. It can be used to access any JDBC driver and database accessible through that driver.

The main benefit of a tool such as ij is that it is easy to run scripts for creating a database schema and automating other repetitive database tasks.

In addition, ij accepts and processes SQL commands interactively for ad hoc database access.

Running ij Scripts

You can run scripts in ij in a few different ways:

ij echoes input from a file if

  • you name an input file as a command-line argument
  • you use the Run command

If you redirect standard input to come from a file, ij does not echo commands.

You can save output by redirecting output to a file or by setting the ij.outfile property. (See ij.outfile.) For example:

java -Djdbc.drivers=COM.cloudscape.core.JDBCDriver
    COM.cloudscape.tools.ij < myscript.sql > myoutput.txt
java -Dij.outfile=myoutput.txt COM.cloudscape.tools.ij
    < myscript.sql

ij automatically shuts down an embedded Cloudscape system (issues a connect `jdbc:cloudscape:;shutdown=true' request) when the Exit command is issued. It does not shut down Cloudscape running in a server framework.

ij exits when the Exit command is entered or if given a command file on the Java invocation line, when the end of the command file is reached.