Latest News

the latest news from our team

JDBC – FAQ

  1. How do I install JDBC on HPUX 10.x

    You will need the HP a C++ run time library files to used the lib3kjdbc.sl (shared library). You can receive these file (if not present on your system) as an HP patch PHSS 22354.

    Java .jar files

    Sun’s Java site is http://www.javasoft.com. This is the main page. It has references to the JDK download page, references to books on Java, and some general Java examples.


  2. What are the parameters and options used to start both the client and server portions of this product?Click on the below link for a list of all the parameters and options used to start both the client and server portions of JDBC:Client ParametersServer Parameters

 

 

What is JDBC?

JDBC is a standard or open application programming interface (API) for accessing a database from JAVA programs. The Minisoft JDBC driver implements this API to give JAVA programs access to data in TurboImage databases, KSAM files, MPE files, Self-describing files, and PowerHouse subfiles.

JDBC is based on and closely aligned with the Open Group standard Structured Query Language (SQL) Call-Level Interface. It allows programs to use SQL requests that will access databases without having to know the proprietary interfaces to the databases. The JDBC driver handles the SQL request and converts it into a request the individual database system understands.

Why use JDBC?

Minisoft’s JDBC driver doesn’t only let you read and write to HP e3000 files as if they were like any other databases it also supports advanced features. Such as access to multiple databases, KSAM files, MPE files, and self-describing files, and support for HP e3000 features like third party indexing and B-trees. This makes Minisoft’s JDBC driver the perfect tool to give JAVA programs access to valuable enterprise data.

Installation

You can receive this product on a set of three diskettes, or you can download it from our Web site.

JDBC from Web Site

Navigate to www.Minisoft.com. Under Product Descriptions select JDBC under Client Server and Web Development Tools, then click Download Minisoft’s JDBC free demo and follow the instructions.

You will then receive three files:

  • JDBC215s.exe, this contains the server software to go to the HP e3000.
  • JDBC215c.exe, this contains the JDBC driver, and the mid-tier server.
  • JDBC215a.exe, this contains the administration software, which you need to install only on one PC; it also contains SCHEMA EDITOR and CATALOG EDITOR.

JDBC diskettes

The Minisoft JDBC driver is shipped on three diskettes:

  • Diskette 1 contains the files for a client installation and this documentation.
  • Diskette 2 contains the files for an administrator installation. Install these files only if you need access to the catalog and schema editor.
  • Diskette 3 contains the files for a server installation. No emulator is needed for this installation. Follow the instructions in the next section to install the files on the three diskettes.

Installing Minisoft JDBC

The Minisoft JDBC driver runs in a 3-tier model. The HP e3000 contains a server program, which it shares with Minisoft’s ODBC/32 driver. A mid-tier server name 3KMidTierListener.exe runs on a Windows NT, Window 98, or Windows 95 machine. It connects JDBC clients to the HP e3000 server. The JDBC driver classes for the client are in MSJDBC.jar. They need to be installed where the JAVA class loader can find them.

Installing the Minisoft JDBC/ODBC/32 host server

This needs to be done only once on one PC—not on each individual JAVA development machine. (Remember that no terminal emulator is needed for this installation.)

  1. Insert diskette 3.
  2. Click Windows’ Start menu on the Taskbar, then click run.
  3. Type: A:\HPSETUP.EXE (A being the letter of your floppy drive).
  4. Follow the on-screen instructions.

NOTE: The Server Installation creates a sample database and populates the customer table. The database that is created is called MSCARD.MM.Minisoft

Read / Write access via JDBC calls

To have the ability to update JDBC you must modify MSJOB. By default the listener job, MSJOB, is installed with the following line that allows read-only access via JDBC calls:

SETVAR MSSERVER000004 “30006 0 ODBCSRVR.MM.Minisoft S”

To enable write / update access, modify the command line to include the “w” (write), option:

SETVAR MSSERVER000004 “30006 0 ODBCSRVR.MM.Minisoft S W”

Installing the Minisoft JDBC driver

  1. Place the JDBC diskette labeled #1 into drive A:\ or B:\.
  2. Run JSETUP.EXE.

This will extract the driver – MSJDBC.jar and the middle-tier server – 3KMidTierListener.exe into the C:\Minisoft\JDBC directory. To use the driver from a Java application, the directory MSJDBC.jar resides in must be listed in the CLASSPATH environment variable. To use the driver from an applet, MSJDBC.jar should be installed on the Web Server, and the directory it resides in should be referenced with the ARCHIVE parameter in the APPLET tag in the appropriate HTML document.

Installing the Minisoft ODBC/32 PC Administrator

Only install the Administrator files if one would need to access the Schema or Catalog Editor. An administrator installment is not necessary to run JDBC.

  1. Place the JDBC diskette labeled #2 into A:\.
  2. Click Windows’ Start menu on the Taskbar, then select Run.
  3. Type; A:\ADMIN.EXE (A being the letter of your floppy drive).
  4. Follow the on screen instructions.

Running the middle-tier server

In order for the mid-tier server, 3KMidTierListener.exe, to accept requests from clients, you must run it. Either set up a short-cut for it, or run it from the Start|Run dialog. By default the mid-tier is listening on port 30504 for client requests. This can be changed with the /P:<port> parameter. Only one copy of 3KMidTierListener.exe should be running on the mid-tier machine, unless the port numbers are different.

Samples

There are two samples provided. They are a Java application (ViewDB.java) and a Java

applet (ViewDBApplet.java). There is also a sample HTML file (ViewDBApplet.htm) supplied to launch ViewDBApplet.

To run the applet, here is a sample of where files would be installed on a Web Server:
ViewDBApplet.htm —> <web root>
ViewDBApplet.class—> <web root>\ViewDBApplet\ViewDBApplet.class
MSJDBC.jar—> <web root>

Datasources

The JDBC driver can use ODBC/32 datasources on the mid-tier machine. ODBC/32 must be on the mid tier machine to create and edit the datasources. The samples show how the datasource is referenced from the Java application or applet.

Basic database access with JDBC

JDBC is a standard and open application programming interface for accessing databases from the JAVA programming language. It allows JAVA programs to use SQL requests that will access databases without having to know the proprietary interfaces to the database. A JDBC driver handles the SQL requests submitting through the JDBC interface and converts them into request the databases the driver supports will understand.

JDBC Classes and Interfaces

The JDBC classes and interfaces are declared in java.sql. The classes are the common components of JDBC. The main class is the DriverManager. You use the DriverManager class to make a connection to a database. Other classes in java.sql are used for date handling, exception handling, and common constants. The interfaces in java.sql are the blueprints used by JDBC driver developers to create a JDBC driver. Each JDBC driver must contain classes that implement the interfaces in java.sql. A typical JDBC driver is a set of these classes, plus some support classes, contained in an archive.

The Big 4

Basic data access through JDBC can be accomplished using only 4 JDBC classes. They are the DriverManager class, the driver’s Connection class, the driver’s Statement class, and the driver’s ResultSet class. Because each of the driver’s classes are implementations of the interfaces described in java.sql, you can access these classes through the interfaces. This means that you only need to specify which driver to use during the connection request. After that the code is driver independent.

The first step in using a JDBC driver is to register it with the DriverManager.

A common way to do this is shown in fig 1a.

The forName method of the Class class returns a Class object associated with the class with the given string name. You really don’t need this, but this code will force the class named by the string to be loaded. The class name of the JDBC driver is “com.Minisoft.jdbc.MSJDBCDriver”. When the JDBC driver is loaded it will register itself with the DriverManager.

Now that the driver is registered with the DriverManager, you can request a connection to a database. The getConnection method of the DriverManager class will do this. This is illustrated in fig 1b.

The string parameter is a url which describes the connection. The first part “jdbc” is the main protocol. The second part “MSJDBC” is a sub-protocol that identifies Minisoft’s JDBC driver. The DriverManager will use the sub-protocol to query each registered driver to see if the driver handles this sub-protocol. The third and subsequent parts identify how to connect to the database. This is driver specific. In this case, using Minisoft’s JDBC driver, the third part is specifying an IP address and port number for the mid-tier server, while the fourth part is specifying a datasource. The datasource contains the HP e3000 specific information to connect to the database(s).

The Minisoft JDBC driver also supports another form of getConnection, in which connection properties can be passed. This form of getConnection is shown in fig 1c.

Refer to the JDBC API reference for a list of all the properties supported. By using this form of getConnection you don’t need a datasource set up on the mid-tier machine. You can specify everything that is needed to connect to the database as a property.

Fig 1a. Registering the driver.

Class.forName( "com.Minisoft.jdbc.MSJDBCDriver" );

Fig 1b. Connecting using a datasource.

Connection con=DriverManager.getConnection
(“jdbc:MSJDBC://127.0.0.1:30504/MSDB”);

Fig 1c. Connecting using connection properties.

String url = “jdbc:MSJDBC://127.0.0.1:30504/”;
Properties p = new Properties();
p.put( “Server”, “data.Minisoft.com” );
p.put( “Server Port”, “31100” );
p.put( “User”, “MGR” );
p.put( “User Password”, “HEREYAGO” );
p.put( “Account”, “Minisoft” );
p.put( “Group”, “MM” );
p.put( “Database0”, “MSDB,DBPSWD,1,5” );
Connection con = DriverManager.getConnection( url, p );

Fig 1d. Creating a Statement object.

Statement stmt = con.createStatement();

Fig 1e. Executing a query that creates a ResultSet object.

ResultSet rs = stmt.executeQuery
( “SELECT * FROM CUSTOMERS” );

Fig 1f. Retriving data from the result set.

while ( rs.next() ) {
s = rs.getString( “CUSTOMER_NUMBER” );
System.out.println( s );
s = rs.getString( “CUSTOMER_NAME” );
System.out.println( s );
s = rs.getString( “ADDRESS1” );
System.out.println( s );
s = rs.getString( “ADDRESS2” );
System.out.println( s );
s = rs.getString( “CITY” );
System.out.println( s );
s = rs.getString( “STATE” );
System.out.println( s );
s = rs.getString( “COUNTRY” );
System.out.println( s );
s = rs.getString( “ZIP” );
System.out.println( s );
s = rs.getString( “DATE” );
System.out.println( s );
}

Fig 1g. Cleaning up.

rs.close();
stmt.close();
con.close();

Fig 1. Using the basic 4 classes to retrieve data from an Turbo Image database

The getConnection method returns an object from the selected driver that conforms to the Connection interface. From now on, objects created by the driver that conform to an interface in java.sql, will be referred to by their interface name, not the internal name of the class in the driver. This is because you never need to know what the internal name is, you always access the object through its interface. The Connection object can now be used to create a Statement object as shown with fig 1d.

The createStatement method of a Connection object returns a Statement object. The Statement object can now be used to execute a SQL query with the executeQuery method. This is illustrated in fig 1e.

This will execute the SQL statement passed as a parameter and create a ResultSet object. The ResultSet object can now be used to retrieve the results of the SQL statement as shown in fig 1f.

The Next method fetches the next record from the result set. The getString method is used to return data from a column. The parameter can be either a column name as a string or a column number ( 1 based ). The getString method is normally used to return alphanumeric columns, although some drivers will return any data type as a string. If you need to retrieve the data in its normal data type, there are get… methods for all the various data types.

It is good practice to exit a program gracefully, although the JDBC driver will take care of things if you don’t. Fig 1g demonstrates the code needed to clean up.

When the close method of a Connection object is called it will call the close method of any Statement objects it created. Similarly, when the close method of a Statement object is called it will call the close method of any ResultSet objects it created. Given this scenario, you could just call con.close.

A complete example that puts together all the above code pieces with added exception handling is shown in fig 2.

import java.sql.*;public class FirstDBAccess
{
public static void main(String[] args)
{
try {
Class.forName( “com.Minisoft.jdbc.MSJDBCDriver” );
String url = “jdbc:MSJDBC://127.0.0.1:30504/MSDB”;
Connection con = DriverManager.getConnection( url );
try {
Statement stmt = con.createStatement();
String query = “SELECT * FROM CUSTOMERS”;
ResultSet rs = stmt.executeQuery( query );
while ( rs.next() ) {
s = rs.getString( “CUSTOMER_NUMBER” );
System.out.println( s );
}
stmt.close();
}
catch ( SQLException e2 )
{
System.out.println( e2 );
}
con.close();
}
catch ( SQLException e0 )
{
System.out.println( e0 );
}
catch ( ClassNotFoundException e1 )
{
System.out.println( e1 );
}
}
}

Fig 2. A complete application that retrieves data from a TurboImage database.

The exception handling catches any exceptions thrown by the JDBC methods. Many of the methods in JDBC can throw a SQLException. Printing out the exception will typically show the error message.

Prepared Statements and Parameters

In many situations you will want to execute essentially the same statement a number of times. The only difference between each execution of the statement might be some selection criteria or update values. For example, if you needed to retrieve customer information by customer number based upon a customer number entered by the user. When the user requested customer number ‘000001’, you could build a string that contained “SELECT * FROM CUSTOMERS WHERE CUSTOMER_NUMBER = ‘000001’” and execute it. Then when the user requested customer number ‘000002’, you would build a string that contained “SELECT * FROM CUSTOMERS WHERE CUSTOMER_NUMBER = ‘000001’” and execute it. This method is very inefficient because the driver will have to compile essentially the same statement many times. The preferred way to accomplish this task is to use a statement that contains parameters and prepared ( compile ) it. Once prepared, you can supply values for the parameters and execute the statement as many times as are needed without compiling it again. Instead of using the createStatement method of a Connection object, you use the prepareStatement method. Its one parameter is a string that contains the SQL statement to prepare. The prepareStatement method returns a PreparedStatement object, which is a subclass of the Statement class. The PreparedStatement class has set… methods to set the values of parameters. Figure 3 illustrates preparing a statement, setting its parameters, and executing it many times.

void DoneOneTime()
{
...
Connection con = DriverManager.getConnection( url );
String query = "SELECT * FROM CUSTOMERS WHERE CUSTOMER_NUMBER = ?";
PreparedStatement stmt = con.prepareStatement( query );

}
void DoneManyTimes( String CustomerNumber )
{
stmt.setString( 1, CustomerNumber );
ResultSet rs = stmt.executeQuery();

}

Fig 3. A prepared statement with parameters.

SQL statements use the question mark (‘?’) to mark the position of parameters. The parameters are numbered, starting at 1, in the order they appear in the statement. The setString method’s first parameter is the parameter number, and its second is the value for the parameter. All parameter values can be cleared with the clearParameters method.

Metadata

Metadata is data which describes data. There are two types of metadata objects that a JDBC driver can provide. One is based upon the DatabaseMetaData interface and the other is based upon the ResultSetMetaData interface.

The DatabaseMetaData class mainly contains methods to get information about a database. The most common information is the names of the tables in the database, and the layout of those tables. Other less frequently used information is access privileges and the relationships between tables. A DatabaseMetaData object is created with the getMetaData method of a Connection object. Figure 4 illustrates using a DatabaseMetaData object to retrieve the names of all the tables in a database.

The getTables method returns a ResultSet object that is used to retrieve the information about the tables. Each row in the result set has 5 columns as follows:

  1. TABLE_CAT String => table catalog (may be null)
  2. TABLE_SCHEM String => table schema (may be null)
  3. TABLE_NAME String => table name
  4. TABLE_TYPE String => table type. Typical types are “TABLE”, “VIEW”, “SYSTEM TABLE”, “GLOBAL TEMPORARY”, “LOCAL TEMPORARY”, “ALIAS”, “SYNONYM”.
  5. REMARKS String => explanatory comment on the table

Depending to the driver, the TABLE_CAT and/or the TABLE_SCHEM columns may be null indicating that these are not attributes of the database the driver supports. Fig. 4 illustrates loading table names into a list box.

...
Connection con = DriverManager.getConnection( url );
Choice tableNames = new Choice();
DatabaseMetaData md = con.getMetaData();
String[] types = { "TABLE" };
ResultSet mrs = md.getTables( null, "", "", types );
while ( mrs.next() ) {
tableNames.addItem( mrs.getString( 3 ) );
}
}
...

Fig. 4. Loading table names into a list box.

The ResultSetMetaData class contains methods to get information about a result set. This information is such things as the number of columns in each row of the result set and the layout of each column. This information is very useful to programs that need to dynamically create the layout for displaying data from a database. A ResultSetMetaData object is created with the getMetaData method of a ResultSet object. Fig. 5 shows how to get and use the data type of a result set column.

String s;
int i;
...
Connection con = DriverManager.getConnection( url );
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery( "SELECT * FROM CUSTOMERS" );
ResultSetMetaData md = rs.getMetaData();
while ( rs.next() ) {
int col;
for ( col = 1; col <= md.getColumnCount; ++col ) {
switch ( md.getColumnType( col ) ) {
case Types.CHAR:
s = rs.getString( col );
...
break;
case Types.INTEGER:
i = rs.getInt( col );
...
break;
...
}
}
}

Fig 5. Using ResultSetMetaData to get a column’s data type.

Adding, updating, and deleting data

JDBC can be used to add, update, and/or delete records in a table. The executeUpdate method of a Statement ( or PreparedStatement ) object is used to execute SQL INSERT, UPDATE, and DELETE statements. The return of the executeUpdate method indicates the number of records affected by the SQL statement. The setting of auto-commit for the Connection object determines if each statement is committed automatically, or if an explicit commit or rollback must be done. If auto-commit is on, then each statement executed with executeUpdate method will be committed immediately. If auto-commit is off, a commit or rollback will only be done when a commit or rollback method of the Connection object is called. By default, new connections start with auto-commit on. Different drivers handle locking, transaction isolation, and concurrency differently. The driver’s documentation will need to be consulted to determine how the driver behaves, and how compatible it will be with other applications that are accessing the database. Fig 6 demonstrates adding a customer record to the customers table, while querying and updating the next value for customer numbers.

Connection con = DriverManager.getConnection( url );
con.setAutoCommit( false );
...
Statement stmt1 = con.createStatement();
ResultSet rs = stm1.executeQuery( "SELECT NEXT_NUMBER FROM NEXT_NUMBERS WHERE CATAGORY = ‘CU’" );
rs.next();
int nextCust = getInt( 1 );
PreparedStatement stmt2 = con.prepareStatement( "INSERT INTO CUSTOMERS (CUSTOMER_NUMBER, ...) VALUES (?,...)");
stmt2.setInt( 1, nextCust );
...
stmt2.executeUpdate();
PreparedStatement stmt3 = con.prepareStatement( "UPDATE NEXT_NUMBERS SET NEXT_NUMBER = ? WHERE CATAGORY = ‘CU’");
stmt3.setInt( 1, ++nextCust );
stmt3.executeUpdate();
con.commit();
...

Fig 6. An INSERT and UPDATE in a single transaction.

JDBC API reference

The following is a reference to the most commonly used methods of the JDBC API. A reference of the complete JDBC API can be found on the JavaSoft web site at www.javasoft.com.

DriverManager Methods

etConnection

public static synchronized Connection getConnection(String url) throws SQLException

public static synchronized Connection getConnection(String url, Properties info) throws SQLException

Requests a connection to a database. If a connection is made, a Connection object is returned.

Parameters:

url – A string which describes the connection in the form “jdbc:MSJDBC://<mid-tier server host name>[:<mid-tier server port>][/<datasource>]. The the main protocol. <mid-tier server host name> and < mid-tier server port> indentify the machine the mid-tier server is running on and the TCP port it is listening on. <datasource> specifies datasource on the mid-tier server machine that contains the HP e3000 specific information to connect to the database(s).

info – A Properties collection that contains the HP e3000 specific information to connect to the database(s). Information in the info parameter will override information contained in a datasource. The available properties are:

2DriverTable – <name of a translation table file for translating data coming to the client>

2HostTable – <name of a translation table file for translating data going from the client>

Account – <HP3000 logon account>

Account Password – <HP3000 logon account password>

Database<n> – <database name to access on the HP3000>,<database password>,<load auto master flag>,<database open mode>

DecimalPoint – <decimal point character>

Group – <HP3000 logon group>

Group Password – <HP3000 logon group password>

Jobname – <jobname>

Langauge – <NLS language>

Schema<n> – <name of the schema file>,<lockword>

Server – <HP3000 IP address or hostname>

Server Port – <server TCP port>

User – <HP3000 user logon>

User Password=<HP3000 user password>

Note:

All property names are case sensitive.

For the properties Database<n>, and Schema<n>, <n> is a number, starting with 0. The first database defined would be with property “Database0”, the second would be with “Database1”, and so on.

The values for <load auto master flag> are 1 to load automatic masters and 0 not to load automatic masters.

The values for <database open mode> are the same as on the DBOPEN intrinsic, i.e. 1 – 8.

Connection Methods

createStatement

public abstract Statement createStatement() throws SQLException

Creates a Statement object. This is typically used when the statement has no parameters and is only going to be executed once.

 

prepareStatement

public abstract PreparedStatement prepareStatement(String sql) throws SQLException

Creates a PreparedStatement object that represents a compiled SQL statement. This is typically used when the statement contains parameters, or when the statement will be executed more than once.

Parameters:

sql – A string which contains the SQL statement to compile.

 

setAutoCommit

public abstract void setAutoCommit(boolean autoCommit) throws SQLException

Sets the state of the connection’s auto-commit mode. If a connection’s auto-commit mode is true, then each statement that modifies the database will be committed upon completion. If a connection’s auto-commit mode is false, then data will only be committed to the database when the commit method is called.

Parameters:

autoCommit – The state to set the auto-commit mode.

 

commit

public abstract void commit() throws SQLException

Commits any changes made by SQL statements since the transaction started to the database. Transactions are automatically started when the first SQL statement that modifies the database is executed.

 

rollback

public abstract void rollback() throws SQLException

Cancels and changes made by SQL statements since the transaction started.

 

close

public abstract void close() throws SQLException

Close the connection and all open databases, statements, and result sets.

 

getMetaData

public abstract DatabaseMetaData getMetaData() throws SQLException

Creates a DatabaseMetaData object. The DatabaseMetaData object is used to provide information about the connection and the open database(s).

 

Statement Methods

executeQuery

public abstract ResultSet executeQuery(String sql) throws SQLException

Compiles and executes a SQL statement and returns a ResultSet object.

Parameters:

sql – A string containing the statement to be executed.

 

executeUpdate

public abstract int executeUpdate(String sql) throws SQLException

Executes a DELETE, INSERT, or UPDATE SQL statement. The return is the number of records effected by the SQL statement.

Parameters:

sql – A String containing the statement to be executed.

 

close

public abstract void close() throws SQLException

Closes the Statement and its current ResultSet if one exists.

 

PreparedStatement Methods

executeQuery

public abstract ResultSet executeQuery() throws SQLException

Executes a previously compiled SQL statement and returns a ResultSet object.

 

executeUpdate

public abstract int executeUpdate() throws SQLException

Executes a previouly compiled DELETE, INSERT, or UPDATE SQL statement.

 

set…

public abstract void setShort(int parameterIndex, short x) throws SQLException

public abstract void setInt(int parameterIndex, int x) throws SQLException

public abstract void setLong(int parameterIndex, long x) throws SQLException

public abstract void setFloat(int parameterIndex, float x) throws SQLException

public abstract void setDouble(int parameterIndex, double x) throws SQLException

public abstract void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException

public abstract void setString(int parameterIndex, String x) throws SQLException

public abstract void setDate(int parameterIndex, Date x) throws SQLException

Set the value of a parameter in a SQL statement.

Parameters:

parameterIndex – The number of the parameter in the SQL statement, starting at 1

x – Ther value for the parameter

 

clearParameters

public abstract void clearParameters() throws SQLException

Clears all SQL statement parameters

 

ResultSet Methods

next

public abstract boolean next() throws SQLException

Fetches the next available row of a result set.

 

close

public abstract void close() throws SQLException

Closes a ResultSet.

 get…

public abstract String getString(int columnIndex) throws SQLException

public abstract short getShort(int columnIndex) throws SQLException

public abstract int getInt(int columnIndex) throws SQLException

public abstract long getLong(int columnIndex) throws SQLException

public abstract float getFloat(int columnIndex) throws SQLException

public abstract double getDouble(int columnIndex) throws SQLException

public abstract BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException

public abstract Date getDate(int columnIndex) throws SQLException

public abstract String getString(String columnName) throws SQLException

public abstract short getShort(String columnName) throws SQLException

public abstract int getInt(String columnName) throws SQLException

public abstract long getLong(String columnName) throws SQLException

public abstract float getFloat(String columnName) throws SQLException

public abstract double getDouble(String columnName) throws SQLException

public abstract BigDecimal getBigDecimal(String columnName, int scale) throws SQLException

public abstract Date getDate(String columnName) throws SQLException

Returns the value of a column from the current row within the result set.

Parameters:

columnIndex – The number of the column to get, starting at 1.

columnName – The name of the column to get.

 

getMetaData

public abstract ResultSetMetaData getMetaData() throws SQLException

Returns a ResultSetMetaData object that has information about this ResultSet.

 

findColumn

public abstract int findColumn(String columnName) throws SQLException

Get a column number that corresponds to a column name.

Parameters:

columnName – The name of the column.

 

ResultSetMetaData Methods

getColumnCount

public abstract int getColumnCount() throws SQLException

Get the number of columns in the ResultSet.

 

getColumnDisplaySize

public abstract int getColumnDisplaySize(int column) throws SQLException

Get the number of characters necessary to display the data from a column.

Parameters:

column – Column number

 

getColumnName

public abstract String getColumnName(int column) throws SQLException

Get the name of a column in the ResultSet.

Parameters:

column – Column number

 

getColumnType

public abstract int getColumnType(int column) throws SQLException

Get the data type of a column in the ResultSet. Data type constants are defined in java.sql.Types.

Parameters:

column – Column number

 

DatabaseMetaData Methods

getTables

public abstract ResultSet getTables(String catalog, String schema, String tableName, String types[]) throws SQLException

Get a ResultSet object containing information about the tables within the database.

Parameters:

catalog – Ignored. Catalogs are not supported by Minisoft’s JDBC driver.

schema – The name of schema to search for tables. A schema name is either a database name or a schema editor file name. If empty all schemas are searched.

tableName – The name of a table to get information about. If empty information about all the tables is returned.

types – An array of strings designating the types of tables to be included. If empty all types are included. The only type supported is “TABLE”.

The columns in the ResultSet are:

  1. TABLE_CAT String => table catalog (may be null)
  2. TABLE_SCHEM String => table schema (may be null)
  3. TABLE_NAME String => table name
  4. TABLE_TYPE String => table type. Typical types are “TABLE”, “VIEW”, “SYSTEM TABLE”, “GLOBAL TEMPORARY”, “LOCAL TEMPORARY”, “ALIAS”, “SYNONYM”.
  5. REMARKS String => explanatory comment on the table

 

getColumns

public abstract ResultSet getColumns(String catalog, String schema, String tableName, String columnName) throws SQLException

Get a ResultSet object containing information about the columns in the table.

Parameters:

>catalog – Ignored. Catalogs are not supported by Minisoft’s JDBC driver.

schema – The name of schema. A schema name is either a database name or a schema editor file name. If empty all schemas are searched.

tableName – The name of a table to get the column information for.

columnName – The name of a column. If empty, include all columns.

The columns in the ResultSet are:

  1. TABLE_CAT String => table catalog (may be null)
  2. TABLE_SCHEM String => table schema (may be null)
  3. TABLE_NAME String => table name
  4. COLUMN_NAME String => column name
  5. DATA_TYPE short => SQL type from java.sql.Types
  6. TYPE_NAME String => Data source dependent type name
  7. COLUMN_SIZE int => column size. For char or date types this is the maximum number of characters, for numeric or decimal types this is precision.
  8. BUFFER_LENGTH is not used.
  9. DECIMAL_DIGITS int => the number of fractional digits
  10. NUM_PREC_RADIX int => Radix (typically either 10 or 2)
  11. NULLABLE int => is NULL allowed?
    • columnNoNulls – might not allow NULL values
    • columnNullable – definitely allows NULL values
    • columnNullableUnknown – nullability unknown
  12. REMARKS String => comment describing column (may be null)
  13. COLUMN_DEF String => default value (may be null)
  14. SQL_DATA_TYPE int => unused
  15. SQL_DATETIME_SUB int => unused
  16. CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column
  17. ORDINAL_POSITION int => index of column in table (starting at 1)
  18. IS_NULLABLE String => “NO” means column definitely does not allow NULL values; “YES” means the column might allow NULL values. An empty string means nobody knows.

 

getIndexInfo

public abstract ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException

Get a ResultSet object containing information about the indexes or keys for the table.

Parameters:

catalog – Ignored. Catalogs are not supported by Minisoft’s JDBC driver.

schema – The name of schema. A schema name is either a database name or a schema editor file name. If empty all schemas are searched.

table – The name of a table to get the column information for.

approximate – Ignored. All statistics are exact.

The columns in the ResultSet are:

  • TABLE_CAT String => table catalog (may be null)
  • TABLE_SCHEM String => table schema (may be null)
  • TABLE_NAME String => table name
  • NON_UNIQUE boolean => Can index values be non-unique? false when TYPE is tableIndexStatistic
  • INDEX_QUALIFIER String => index catalog (may be null); null when TYPE is tableIndexStatistic
  • INDEX_NAME String => index name; null when TYPE is tableIndexStatistic
  • TYPE short => index type:
    • tableIndexStatistic – this identifies table statistics that are returned in conjuction with a table’s index descriptions
    • tableIndexClustered – this is a clustered index
    • tableIndexHashed – this is a hashed index
    • tableIndexOther – this is some other style of index
  • ORDINAL_POSITION short => column sequence number within index; zero when TYPE is tableIndexStatistic
  • COLUMN_NAME String => column name; null when TYPE is tableIndexStatistic
  • ASC_OR_DESC String => column sort sequence, “A” => ascending, “D” => descending, may be null if sort sequence is not supported; null when TYPE is tableIndexStatistic
  • CARDINALITY int => When TYPE is tableIndexStatistic, then this is the number of rows in the table; otherwise, it is the number of unique values in the index.
  • PAGES int => When TYPE is tableIndexStatisic then this is the number of pages used for the table, otherwise it is the number of pages used for the current index.
  • FILTER_CONDITION String => Filter condition, if any. (may be null)

Leave a Reply

Your email address will not be published. Required fields are marked *