Community Wiki

Ingres JDBC Driver Properties

From Ingres Community Wiki

Jump to: navigation, search

I. Introduction

This simple example illustrates how to get the properties supported by the Ingres JDBC driver. The output of the program is in XML format. Please feel free to change the display format the way you prefer. The Ingres JDBC driver ( iijdbc.jar ) from Ingres2006r2 installation is used for testing. It is assumed that the reader is familiar with Java/JDBC programming.


II. The Example Program

The example program can also be downloaded by clicking this link: Media:IngDrivProp.java.

import java.sql.Driver;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;
import java.sql.DriverPropertyInfo;
// Name: IngDrivProp.java
//
// Description:
// Displays the Ingres JDBC driver properties in XML format. Requires
// JDK 1.5.x and beyond for compiling/running.
//
// History:
// 31-Dec-2007 ( Usha Rajsekar )
// Created.
//
public class IngDrivProp
{
public static final String ING_DRIVER = "com.ingres.jdbc.IngresDriver";
public static final String ING_DRIVER_URL = "jdbc:ingres://host:port/db";
public static void main( String[] args ) throws Exception
{
try
{
Class.forName(ING_DRIVER);
}
catch( Exception ex )
{
throw new Exception(" Unable to load Ingres JDBC driver class: " + ex );
}
try
{
StringBuilder str_buf = new StringBuilder();
Properties prop = new Properties();
Driver drv = DriverManager.getDriver(ING_DRIVER_URL);
DriverPropertyInfo[] prop_info = drv.getPropertyInfo(ING_DRIVER_URL, prop);
// Process property info
if( prop_info != null )
{
str_buf.append("\n<driver_properties>\n\n");
for(int i = 0; i < prop_info.length; i++ )
{
String name = prop_info[i].name;
boolean req = prop_info[i].required;
str_buf.append(" <property name=\"");
str_buf.append(name);
str_buf.append("\" required=\"");
str_buf.append(req);
str_buf.append("\">\n");
String val = prop_info[i].value;
str_buf.append(" <value>");
str_buf.append(val);
str_buf.append("</value>\n");
String desc = prop_info[i].description;
str_buf.append(" <description>");
str_buf.append(desc);
str_buf.append("</description>\n");
String[] val_choices = prop_info[i].choices;
if( val_choices != null )
{
str_buf.append(" <choices>\n");
for(int c = 0; c < val_choices.length; c++ )
{
str_buf.append(" <choice>");
str_buf.append(val_choices[c]);
str_buf.append("</choice>\n");
}
str_buf.append(" </choices>\n");
}
str_buf.append(" </property>\n");
}
}
str_buf.append("\n</driver_properties>\n");
System.out.println(str_buf.toString());
}
catch( Exception ex )
{
throw new Exception(" Unable to generate Ingres JDBC driver properties: " + ex );
}
}//main
}

III. The program output in XML format

 <driver_properties>
 <property name="database" required="true">
   <value>db</value>
   <description>Database</description>
 </property>
 <property name="user" required="false">
   <value>null</value>
   <description>User ID</description>
 </property>
 <property name="password" required="false">
   <value>null</value>
   <description>Password</description>
 </property>
 <property name="group" required="false">
   <value>null</value>
   <description>Group ID</description>
 </property>
 <property name="role" required="false">
   <value>null</value>
   <description>Role ID</description>
 </property>
 <property name="dbms_user" required="false">
   <value>null</value>
   <description>DBMS User ID</description>
 </property>
 <property name="dbms_password" required="false">
   <value>null</value>
   <description>DBMS Password</description>
 </property>
 <property name="connect_pool" required="false">
   <value>null</value>
   <description>Connection Pool</description>
   <choices>
     <choice>off</choice>
     <choice>on</choice>
   </choices>
 </property>
 <property name="autocommit_mode" required="false">
   <value>dbms</value>
   <description>Autocommit Mode</description>
   <choices>
     <choice>dbms</choice>
     <choice>single</choice>
     <choice>multi</choice>
   </choices>
 </property>
 <property name="vnode_usage" required="false">
   <value>connect</value>
   <description>VNODE Usage</description>
   <choices>
     <choice>connect</choice>
     <choice>login</choice>
   </choices>
 </property>
 <property name="select_loop" required="false">
   <value>off</value>
   <description>Select Loops</description>
   <choices>
     <choice>off</choice>
     <choice>on</choice>
   </choices>
 </property>
 <property name="cursor_mode" required="false">
   <value>dbms</value>
   <description>Cursor Mode</description>
   <choices>
     <choice>dbms</choice>
     <choice>readonly</choice>
     <choice>update</choice>
   </choices>
 </property>
 <property name="char_encode" required="false">
   <value>null</value>
   <description>Character Encoding</description>
 </property>
 <property name="timezone" required="false">
   <value>null</value>
   <description>Timezone</description>
 </property>
 <property name="decimal_char" required="false">
   <value>null</value>
   <description>Decimal Character</description>
 </property>
 <property name="date_format" required="false">
   <value>null</value>
   <description>Date Format</description>
 </property>
 <property name="money_format" required="false">
   <value>null</value>
   <description>Money Format</description>
 </property>
 <property name="money_precision" required="false">
   <value>null</value>
   <description>Money Precision</description>
 </property>
 </driver_properties>
Personal tools